Cleanup function in the useEffect hook.
The useEffect hook is built in a way that if we return a function within the method, this function will execute when the component gets disassociated. This is very useful because we can use it to remove unnecessary behavior or prevent memory leaking issues.
if we add return inside useEffect it will immediately before a component is unmounted and destroyed. It is a good place to do some cleanup works.
#jasacadamy #reactjs #hooks