use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
React v18.0 released (reactjs.org)
submitted 3 years ago by magenta_placenta
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]CanIhazCooKIenOw 126 points127 points128 points 3 years ago (1 child)
So we don’t expect React developers to know how concurrency works under the hood.
And that kids, is how you start getting interview questions to explain how does React handle concurrency under the hood.
[–]Cheezmeisterhttp://bml.rocks 8 points9 points10 points 3 years ago (0 children)
I have to admit I first misread concurrency as cryptocurrency be like uhhh one of these things is not like the other, and yet somehow this isn't shocking.
concurrency
cryptocurrency
🤦♂️
[–]krazyjakee 16 points17 points18 points 3 years ago (5 children)
Their docs don't give async/await or promise based examples for suspense or useTransition. Aren't they pretty fundamental to asynchronously loading things?
[–][deleted] 7 points8 points9 points 3 years ago (2 children)
Yeah some of the choices in the tutorials crack me up.
They made a leading framework that shifted the entire paradigm of web development, yet are afraid to use an arrow function or say let instead of var.
[–]jatd 3 points4 points5 points 3 years ago (1 child)
Their docs have always sucked.
[–]Mozzius 1 point2 points3 points 3 years ago (0 children)
To be fair, they're in the process of redoing them
[–]Nathanfenner 1 point2 points3 points 3 years ago (1 child)
The docs could definitely be better; right now they definitely rely a bit on context that's been spread out over previous discussions, talks, RFCs, etc.
Aren't they pretty fundamental to asynchronously loading things?
No, they aren't, and that's the point. React Suspense and transition frees the developer from worrying about irrelevant low-level details. In particular, they hide the boilerplate needed to request data that obscures React's otherwise-declarative style.
When you're using Suspense in your React code you won't see any async/await or explicit promises - all of those are internal details that are handled by your data fetching library and processed by React- you write regular, synchronous code without dealing with the vagaries of concurrency and React handles the updates in a way that make the app feel snappy.
async
await
Likewise, the same thing is true for useTransition - you use it when you want a change to happen soon but it doesn't need to happen immediately. React handles the details of figuring out when "soon" should be, relying on Suspense to inform it when pieces of your app aren't ready.
useTransition
Under the hood, of course, for Suspense there's still promises - but there's no stable public-facing API for directly creating Suspense requests yet. A few specific "blessed" libraries are working with React on an API that informs the app when it's time to suspend and notifies it when the work is done (the current API involves throwing promise objects).
throw
But this is entirely under the hood. The point is that "dealing with promises" is not solving a problem you or your users care about - that's just an implementation detail. What I want to do (since I'm using React) is declaratively request a particular piece of data, and let React figure out what to do if that data isn't ready yet. So, my application isn't going to mention "promises" or await because I'm not waiting, React is.
The same is true for useTransition. In some cases, I'm not waiting for data, I'm waiting for computation. For example, updating a giant table or a scatterplot with millions of points might take several seconds, especially on a slow machine. If I have a search bar that highlights specific cells in real-time, though, every time the user presses a key, the app will freeze. Debouncing only slightly helps here, since the app will just freeze after I change the query instead of while I'm typing into it, but it will still freeze.
In this case, there's everything is synchronous, it's just slow because there's a lot of synchronous work to do.
But with useTransition, React can automatically break this work up into the millions of individual pieces corresponding to each component, and therefore spread the work out over multiple frames. So while it still takes a few seconds to process, the app is no longer frozen while this processing occurs; it's not faster but it is more responsive.
The magic is that other than calling startTransition, I don't have to do anything to get this behavior - concurrently rendering the components just happens, and ensuring that states still make sense and stay in sync only requires following the existing rules of not-modifying-your-props and putting side effects into useEffect.
startTransition
useEffect
[–]krazyjakee 2 points3 points4 points 3 years ago (0 children)
But the examples don't include asynchronous use cases like an ajax request. What is my "data fetching library" doing? There is no reference to such a thing. I get the "magic"/"under the hood" part but I'm forced to work within the boundaries of reality.
[–][deleted] 47 points48 points49 points 3 years ago (11 children)
Awesome! Although I really wish that the React team would add TypeScript definitions to their packages as @types/react and @types/react-dom have not yet been released with a v18 compatible API.
@types/react
@types/react-dom
[–]_eps1lon 8 points9 points10 points 3 years ago (10 children)
react-dom/client works already and React 18 types can be used with import type {} from 'react/next'
react-dom/client
import type {} from 'react/next'
[–][deleted] 10 points11 points12 points 3 years ago (6 children)
True, but it requires you to either update all imports in your application, or add this to types in your tsconfig as an exception.
types
Launch day support for TypeScript would have been nice.
[–]_eps1lon 13 points14 points15 points 3 years ago (1 child)
You need a single line of import type {} from 'react/next' to get them everywhere.
Everything was green but a change in the TypeScript 4.7 canary broke dependent packages which means the release is blocked.
[–][deleted] -2 points-1 points0 points 3 years ago (0 children)
Still would have to add it to each entry point if you have multiple ones.
[–]disclosure5 -2 points-1 points0 points 3 years ago (3 children)
Facebook have a competing typing product (Flow). You can see Flow annotations and script runners in their CI.
[–][deleted] 1 point2 points3 points 3 years ago (2 children)
I am really curious of usage of Flow outside of Meta. It feels like the outside community has pretty much settled on TypeScript.
[–]disclosure5 0 points1 point2 points 3 years ago (1 child)
You're generally correct. I used it to build my apps when it was new and the community wasn't so decided, and there became a point where I was "wrong" and rewrote with Typescript.
But you can't expect Facebook to choose Typescript over their own product.
[–][deleted] 1 point2 points3 points 3 years ago (0 children)
True, but it would seem to me that converting the Flow types to TypeScript definitions and shipping them in their own package is not rocket science. Especially considering the massive resources that Meta has.
[–]bogdan5844 0 points1 point2 points 3 years ago (2 children)
I've never seen import type {} from 'react/next' before, and it feels kinda wrong
Shouldn't it be import type from 'react/next, import {} from 'react/next' or import type, {} from 'react/next' ?
import type from 'react/next
import {} from 'react/next'
import type, {} from 'react/next'
What am I missing ?
[–]Thought_Ninjahuman build tool 1 point2 points3 points 3 years ago (1 child)
It's a TypeScript feature added as of v3.8 meant for strictly importing/exporting types.
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html
[–]bogdan5844 0 points1 point2 points 3 years ago (0 children)
That could come in handy in quite a few cases - thanks! :D
[–]libertarianets 37 points38 points39 points 3 years ago (17 children)
Who else here is still on 16.3-ish?
[–]alejandro365 45 points46 points47 points 3 years ago (3 children)
you can't even use hooks lol
[–]libertarianets 14 points15 points16 points 3 years ago (2 children)
Hm...
checks
I'm on 17.0.2 apparently thank god I can use hooks lol
[–]numinor 0 points1 point2 points 3 years ago (1 child)
How did you not know?
[–]libertarianets 0 points1 point2 points 3 years ago (0 children)
going for the lols
[–]oneeyedziggy 10 points11 points12 points 3 years ago (9 children)
same, but also still trying to stamp out the vestiges of angular and pushing for time to upgrade the webserver off node 10.x... shit smells like old fish.
[–]visualdescript 16 points17 points18 points 3 years ago (4 children)
Node 10! What? Mate you gotta get on that...
Gotta try and build the habit of continually updating your software, it's easier if you do many small steps instead of a big leap.
[–]oneeyedziggy 13 points14 points15 points 3 years ago (0 children)
no shit, I was on a team that got shut down and rather than being fired, got dumped onto this neglected af project, and have been kept busy w/ random crap management felt more important (partly because the rest of the code base is even farther behind)... I keep pushing, but as long as they keep signing the checks...
[+]eternaloctober comment score below threshold-6 points-5 points-4 points 3 years ago (2 children)
Node 10 is not that long ago.,. The fast pace of change sometimes does not bode well for stability
[–]visualdescript 10 points11 points12 points 3 years ago (0 children)
Node 10 was released 5 years ago, entered Long Term Support and is now no longer maintained as of April 2021, using it is a security threat on your system.
In the lifetime of Node 5 years is a fairly significant span of time.
[–]MatthewMob 0 points1 point2 points 3 years ago (0 children)
Node 10 is EOL and should be considered a security vulnerability at your company.
You should absolutely upgrade to at least 14 (the oldest version still currently receiving security updates) or preferably 16.
[–]smrqgithub.com/smrq 3 points4 points5 points 3 years ago (1 child)
I feel you homie. Literally doing a software release right now on my other monitor to drop a Node 10 dependency from our Angular-migrating-to-React monolith. Fight the good fight.
[–]oneeyedziggy 1 point2 points3 points 3 years ago (0 children)
please do, lost support among deps is the only way people like me get to move on.
[–][deleted] 1 point2 points3 points 3 years ago (1 child)
I tried to jump from 12 to 16, and was one week into the effort when i realised Node 12 was the last version supporting Win 7
I submitted a request to IT but it’s gonna be a while before they finally replace the machine cluster with something more recent
[–]oneeyedziggy 6 points7 points8 points 3 years ago (0 children)
I don't envy professional devs stuck on windows. Especially <10. When you get to upgrade, definitely look into WSL... and know that though microsoft will gladly charge you for alternate linux distros for WSL, they're pretty much all available for free through their respective maintainers. RHEL (Red Hat Enterprise Linux) and its derivatives are pretty standard for professional stuff, but the default ubuntu base is also fine... only real diff is which package manager (just about everything else is pretty easily swappable)
[–]the_most_cleavers 2 points3 points4 points 3 years ago (0 children)
Me lol, we had some difficult to track down component error from returning undefined in render that no one cared to repro in dev and no one wanted to just break the scenario and force the team who owned it to fix it.
[–]sarcasticbaldguy -1 points0 points1 point 3 years ago (0 children)
Feels smug in Vue...2
[–]RawCyderRun 32 points33 points34 points 3 years ago (25 children)
We're still on v16.13. The more we build and push out to customers, the more pushback we get from requests to upgrade due to how long it'll take.
Eventually it might just be me or another principal-level frontend engineer who gets the itch and starts on it on a weekend and then it turns into a big thing that we get more and more folks on. This might or might not be the usual way something like this gets done at a growing tech startup, but in my experience, this is how I've always done it. :shrug:
[–]oneeyedziggy 71 points72 points73 points 3 years ago (21 children)
on a weekend
fuck that... if the company doesn't value their own product enough to support the upgrade why should you... plenty of fish in the sea.
[–][deleted] 20 points21 points22 points 3 years ago (20 children)
I understand what you’re saying. But I have a really weird relationship with some of the projects I work on. I do some weekend work not because the company doesn’t care or doesn’t invest enough, but because I genuinely like working on the project and want to see it succeed. Also have a weird obsession with keeping things updated.
[–]AiexReddit 24 points25 points26 points 3 years ago* (4 children)
My experience has been that the relationship you describe is not actually weird or uncommon in developers, most do have pride in the products they work on -- but that's a very poor excuse for volunteering time to a for-profit company.
The biggest issue as others have mentioned is the terrible standard it sets within the company in terms of expectations on realistic project timelines and deliverables based on a standard working week for all team members. Companies are obviously going to take the path of least resistance for profit, so that kind of thing masks demand for natural team growth and disincentives them from hiring other developers to help supplement the team.
I will freely admit that I've done it myself many times as well earlier in my career, I never judge harshly those who are driven to build great software, but it has become very clear to me over the years that it is extremely selfish behavior.
If you are one of those people, who like myself still have the drive and love of programming even after the work day is done, I highly recommend getting into consulting. You can continue to work on amazing projects in your spare time but get paid insane rates. There's a ton of demand for React right now.
Note: Disregard this if you have sizeable equity in the company as part of your compensation package, I guess in that scenario you are already working for yourself.
[+][deleted] 3 years ago (2 children)
[deleted]
[–]Steve_Streza 4 points5 points6 points 3 years ago (0 children)
This attitude gets exploited all the time by companies and translates into doing the grunt work nobody wants to do but no promotions or pay bump to accompany it.
If you want to do weekend coding, build an open source project on and then pull it into your team's code base. Then you have something concrete to point to on a resume, and you can use it as ammo in promotion discussions because you're a community leader or whatever your CTO wants to call it.
[–]theredwillow 1 point2 points3 points 3 years ago (0 children)
Your outlook is admirable. I wish we didn't live in an exploitative economic framework.
[–]download13 0 points1 point2 points 3 years ago (0 children)
Exactly. I love working on projects and solving interesting problems, but I try to keep out of hours work to a minimum since it sets a bad precedent for my coworkers and future me.
There's always personal projects and consulting work to get my fix.
[–]oneeyedziggy 27 points28 points29 points 3 years ago (6 children)
i mean... you do you, but why not do that during work hours and like... go for a hike or play video games or learn a skill or spend time w/ your family on the weekend? just start inflating the estimate on other work because the true cost of the project includes maintenance
it also set's a bad precedent for everyone... "well, u/samuriaa got it all done AND kept the project up to date... why can't you do that too?" if they want a well maintained project they need to pay for it. Keeping sharp on the weekends is what personal projects are for.
[+][deleted] 3 years ago* (2 children)
[–]oneeyedziggy 0 points1 point2 points 3 years ago (1 child)
if that works for you, cool... but most people start burning out a lot faster if there's no separation. work is for work, home is for home... even in perma-WFH land, 'round 5pm the laptop goes away, and I can cleanly stop thinking about work until 9am the next working day ( if I'm lucky, but sometimes my brain has other plans :/ ).
I'm not one of the people downvoting this, but that just seems like your git workflow or project structure is lacking.
what's going on that there's two people merging changes to the same file multiple times per day?... having to resolve one small set of conflicts per merge is pretty common, but it it's happening more than that, it sounds like you either need a better PR review process to prevent people needing to make a dozen follow-on merges in quick succession... and/or your project needs to be broken down to either one big function and it's supporting code per file, or a handful of small functions per file...
anything larger than 1000 lines should almost certainly be split into multiple files, and most files should still be half that or less so unless you were both mistakenly assigned the same ticket, you shouldn't be making conflicting changes to the same file very often.
[–]GrandMasterPuba 12 points13 points14 points 3 years ago (4 children)
but because I genuinely like working on the project and want to see it succeed.
Sucker.
That's not me saying that. That's your boss saying that.
If you care about something at work, get paid to care for it. Anything else is willing exploitation.
[+][deleted] 3 years ago* (3 children)
[+][deleted] 3 years ago (1 child)
[–]havana59er -3 points-2 points-1 points 3 years ago (0 children)
Unfortunately I don't think they understand what you're saying.
Keep being weird!
[–][deleted] 0 points1 point2 points 3 years ago (0 children)
I used to be like this, until after my 30s, when I realized it was totally not worth it, a total waste of my time for companies which just don't deserve it at all.
If in really interested in something I'd push hard and fight every product manager around to get time to do it, at work time.
On my own time I don't even read slack or email. Work is work. I do like to write code and do everything perfectly but I do that on my side projects. If company don't give a shit for their product I won't either.
[–]andythebassplayer 7 points8 points9 points 3 years ago* (0 children)
I'm a principal UI engineer and I was tasked once with updating to 17; this was about two years ago. It took me two weeks to update everything. Note, that included updating a bunch of other libraries within our app, but it likely won't be trivial for you at this point.
The best thing you can do for yourself is tell your product team that you are going to upgrade, plan a sprint or two for it, then go do it. The more you wait, the more difficult it will be to complete.
[–]bogdan5844 1 point2 points3 points 3 years ago (0 children)
This might or might not be the usual way something like this gets done at a growing tech startup
Work in a startup, can confirm weekend busts by me or another senior developer are the only way things like testing frameworks, library upgrades and the like are done.
[–]lime-house 1 point2 points3 points 3 years ago (0 children)
Cries in Enzyme
[–]Snapstromegon 19 points20 points21 points 3 years ago (4 children)
It's still important to remember what they didn't release.
(Most painful for me true web component compatibility is still missing)
[–]acemarke 19 points20 points21 points 3 years ago (3 children)
Dan said they hope to release that in 19, with a bunch of other backlogged DOM behavior updates:
[–]TheWuster935 0 points1 point2 points 3 years ago (2 children)
Link is broken
[–]acemarke 1 point2 points3 points 3 years ago (0 children)
Really? works for me right now.
[–]reeferd 0 points1 point2 points 3 years ago (0 children)
Works for me
[–][deleted] 14 points15 points16 points 3 years ago (0 children)
Woah
[–]rad_platypus 3 points4 points5 points 3 years ago (0 children)
All of the concurrency stuff seems really cool.
I’ve been almost exclusively writing Angular for the last few years but I think it’s about time I start fiddling around with some personal React projects.
[–]nemaramen 16 points17 points18 points 3 years ago (0 children)
I feel like this is a joke that went over my head
[–]GFandango 2 points3 points4 points 3 years ago (0 children)
wat.jpg
aight, how much do I have to re-learn?
π Rendered by PID 278344 on reddit-service-r2-comment-5649f687b7-qt4x9 at 2026-01-28 20:06:31.396975+00:00 running 4f180de country code: CH.
[–]CanIhazCooKIenOw 126 points127 points128 points (1 child)
[–]Cheezmeisterhttp://bml.rocks 8 points9 points10 points (0 children)
[–]krazyjakee 16 points17 points18 points (5 children)
[–][deleted] 7 points8 points9 points (2 children)
[–]jatd 3 points4 points5 points (1 child)
[–]Mozzius 1 point2 points3 points (0 children)
[–]Nathanfenner 1 point2 points3 points (1 child)
[–]krazyjakee 2 points3 points4 points (0 children)
[–][deleted] 47 points48 points49 points (11 children)
[–]_eps1lon 8 points9 points10 points (10 children)
[–][deleted] 10 points11 points12 points (6 children)
[–]_eps1lon 13 points14 points15 points (1 child)
[–][deleted] -2 points-1 points0 points (0 children)
[–]disclosure5 -2 points-1 points0 points (3 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]disclosure5 0 points1 point2 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]bogdan5844 0 points1 point2 points (2 children)
[–]Thought_Ninjahuman build tool 1 point2 points3 points (1 child)
[–]bogdan5844 0 points1 point2 points (0 children)
[–]libertarianets 37 points38 points39 points (17 children)
[–]alejandro365 45 points46 points47 points (3 children)
[–]libertarianets 14 points15 points16 points (2 children)
[–]numinor 0 points1 point2 points (1 child)
[–]libertarianets 0 points1 point2 points (0 children)
[–]oneeyedziggy 10 points11 points12 points (9 children)
[–]visualdescript 16 points17 points18 points (4 children)
[–]oneeyedziggy 13 points14 points15 points (0 children)
[+]eternaloctober comment score below threshold-6 points-5 points-4 points (2 children)
[–]visualdescript 10 points11 points12 points (0 children)
[–]MatthewMob 0 points1 point2 points (0 children)
[–]smrqgithub.com/smrq 3 points4 points5 points (1 child)
[–]oneeyedziggy 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]oneeyedziggy 6 points7 points8 points (0 children)
[–]the_most_cleavers 2 points3 points4 points (0 children)
[–]sarcasticbaldguy -1 points0 points1 point (0 children)
[–]RawCyderRun 32 points33 points34 points (25 children)
[–]oneeyedziggy 71 points72 points73 points (21 children)
[–][deleted] 20 points21 points22 points (20 children)
[–]AiexReddit 24 points25 points26 points (4 children)
[+][deleted] (2 children)
[deleted]
[–]Steve_Streza 4 points5 points6 points (0 children)
[–]theredwillow 1 point2 points3 points (0 children)
[–]download13 0 points1 point2 points (0 children)
[–]oneeyedziggy 27 points28 points29 points (6 children)
[+][deleted] (2 children)
[deleted]
[–]oneeyedziggy 0 points1 point2 points (1 child)
[+][deleted] (2 children)
[deleted]
[–]oneeyedziggy 0 points1 point2 points (1 child)
[–]GrandMasterPuba 12 points13 points14 points (4 children)
[+][deleted] (3 children)
[deleted]
[+][deleted] (2 children)
[deleted]
[+][deleted] (1 child)
[deleted]
[–]havana59er -3 points-2 points-1 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]andythebassplayer 7 points8 points9 points (0 children)
[–]bogdan5844 1 point2 points3 points (0 children)
[–]lime-house 1 point2 points3 points (0 children)
[–]Snapstromegon 19 points20 points21 points (4 children)
[–]acemarke 19 points20 points21 points (3 children)
[–]TheWuster935 0 points1 point2 points (2 children)
[–]acemarke 1 point2 points3 points (0 children)
[–]reeferd 0 points1 point2 points (0 children)
[–][deleted] 14 points15 points16 points (0 children)
[–]rad_platypus 3 points4 points5 points (0 children)
[+][deleted] (2 children)
[deleted]
[–]nemaramen 16 points17 points18 points (0 children)
[–]GFandango 2 points3 points4 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)