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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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.