Goodbye, useEffect: David Khourshid
Video Statistics and Information
Channel: Real World React
Views: 224,749
Rating: undefined out of 5
Keywords:
Id: HPoC-k7Rxwo
Channel Id: undefined
Length: 26min 0sec (1560 seconds)
Published: Fri May 27 2022
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
Much of this presentation makes me uncomfortable.
Yes hooks are overused. Lifecycle methods were overused before too. It's often a cleaner and more flexible design to save React components for rendering and do everything else somewhere else. That's ultimately where this presentation goes by the end and to that extent I agree with it.
But React is now the dominant UI library for client-side rendering of web apps. We are way past the point where Hyrum's Law becomes relevant. And whether or not it is a good idea the reality is that many teams have shoved the kitchen sink into their React components and the presentation of hooks has actively encouraged that style. Developers do rely on the behaviour of
useEffect
or on hooks from libraries like react-query and swr that are used in a similar way. If you're going to pretend that React is being maintained and made available for general use by the community and not just as something for internal use at Facebook then aspects like compatibility and having good documentation are really important.I think what is really annoying me here is the argument made several times in this presentation that the "official" line is X or the "intended" use of something is Y. Says who? The official React documentation for
useEffect
presents almost exactly the opposite perspective and has for several years. The source for the irritating claims seems to be some mostly unacknowledged goalpost moving in the new documentation that is years late and still not finished. And the big argument about multiple renders causing repeated effects relies on some potentially surprising behaviour changes in a version of React that was only released a couple of months ago when hooks have been in widespread use for well over three years now.In short the attitude here seems to be a combination of casually dismissing the impact these changes might have on huge numbers of applications that have followed widely used patterns for several years and gaslighting as if the failure of those patterns to work as expected any more is their developers' fault and not because of a very recent change in direction from the React developers that actively changes behaviour in surprising ways.
More confusion, more quirks, still no documentation, this bs pisses me off.
TLDW? In general it's good to summarise longer videos.
Okay what I understand is that React 18 is making me change where I fire async network calls, because I do not want those firing twice. Oh, and its not immediately clear how this common use case is handled. great.
Person in the video here, thanks for sharing!
There's a lot to talk about with regard to
useEffect()
, and I wasn't able to capture it all in this talk. In future talks, I will be discussing new patterns, updated React core team guidance, and more fundamentals on effects in React.Feel free to ask me any questions about this talk, happy to answer them.
React the library which creates problems for other libraries to solve.
React honestly makes angular look very appealing these days
What can I say, front end development is really tiresome and tiring.
I'm baffled that people would ever do this pattern on the left.
What would lead someone to think they ever needed
useEffect
for this pattern? This is something that has existed since the class component days.useEffect
is not some fancy place to just put any effect (as said in the talk). It's just a way to hook into an effect which is based off of prop values changing. Creating internal state which you change the value of so that youruseEffect
fires again is crazy and shouldn't happen in any version of react, regardless of react 18, 17, or w/e version you are on.To clarify:
Let's look at the example in terms of old class components. This would be the equivalent of setting your "fetching" state to true, then in
componentDidUpdate
, checking if fetching state changed, and if it did, submit for your form. No one would ever do that!