DEV Community

Discussion on: React Lifecycle Methods and Hooks

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.