Twitter | Search | |
Adam Klein 24 Jan 19
Reply Retweet Like
Ryan Florence 24 Jan 19
Gotta stop thinking about it as the old life cycles with the [] trick. It’s an effect, and you need to clean up your effects that are long running. Return your cleanup function, declare your dependencies, no bugs. setTimeout, like in my talk at react conf, is the better model.
Reply Retweet Like
Ryan Florence
I’ve had a lot of people point to setInterval with hooks as some sort of egg on React’s face when it’s about the only example of stale state I’ve seen. If that’s the hardest thing in hooks then we are light years beyond class complexity 🤘🏼
Reply Retweet Like More
Adam Klein 25 Jan 19
I'm actually in love with hooks, and been giving talks about how awesome it is. Just showing the gotchas and challenging my fellow twitter friends :)
Reply Retweet Like
Ryan Florence 25 Jan 19
Then I’ll challenge you, come up with another stale state example 😛
Reply Retweet Like
Dan Abramov 4 Feb 19
Just leaving this here!
Reply Retweet Like
Adam Klein 4 Feb 19
Awesome! I love it that you see a repeating question/problem and write a very detailed post about it. One question - will it work well to pass [delay, callback] to the useEffect array param instead of saving the callback on a ref?
Reply Retweet Like