Today I learned
Missusing useEffect
Today I learned that Reacts useEffect is not meant for data fetching and is
not a state setter either!
This questions all my best practices I’ve applied over the last years since we got useEffect.
David K. Piano held this amazing talk about our wrong understanding of useEffect and what the alternatives are. So, good bye useEffect?
His key takeaways were the following:
- the default behaviour of
useEffectis an infinite loop useEffectis not for effectsuseEffectis not a lifecycle hookuseEffectis not a state setteruseEffectshould actually be calleduseSynchronize, because it's meant to synchronize React with external systems
I hope you enjoyed this post and learned something new. If you have any questions, feel free to reach out to me via Email.
If you want to support me, you can buy me a coffee. I would be very happy about it!
☕️ Buy me a coffee ☕️I wish you a wonderful day! Marco