DEV Community

Cover image for React Lifecycle Methods and Hooks

React Lifecycle Methods and Hooks

Sayuj Sehgal on March 10, 2024

If you like this blog, you can visit my personal blog sehgaltech for more content. Welcome back, React warriors! Today we explore fascinating wo...
Collapse
 
brense profile image
Rense Bakker

If you're going to use React hooks, it's best to completely forget about lifecycle methods. The useEffect hook is used to handle side effects, like triggering fetch requests, or handling event listeners that are not part of the React scope. The cleanup function that is returned from the useEffect hook is used to cleanup that side effect.

Btw, class components and therefore lifecycle methods are deprecated and should not be used anymore, which is a good thing, because forgetting about lifecycle methods frees up your mind to learn about programming concepts that are not specific to React.