blog/react-core-concept-useeffect #321
Replies: 3 comments 1 reply
-
|
Hello, kindly leave a like (or 5 😄), and comment if you got something to ask! 🚀 |
Beta Was this translation helpful? Give feedback.
-
|
I have to say, even you're younger than me, I even learn a lot from you. Your articles, especially about the fundamental ones, that makes me can reach this point in my career. Thank you for sharing this🚀 |
Beta Was this translation helpful? Give feedback.
-
|
This is a good introduction to useEffect, but you missed a crucial feature - its cleanup function - which gets run when the component either un-mounts, or before the effect runs again - this is especially important for avoiding memory leaks - or for cleaning up from subscriptions to data-sources (say an external store or a browser api like IntersectionObserver) Another good note would be using eslint with the exhaustive dependencies rule which helps with dependency arrays & not running into issues with that (when you're a beginner) Finally its also good to include that useEffect only runs after the browser has finished its first paint - which sometimes might not be the right time, especially if your effect modifies layout etc... (in which case useLayoutEffect would be the better choice) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
blog/react-core-concept-useeffect
An in-depth look at the useEffect hook in React with a mental model
https://theodorusclarence.com/blog/react-core-concept-useeffect
Beta Was this translation helpful? Give feedback.
All reactions