7th Practical Class:
useEffect
React Component Lifecycle
hook
Effect on Mount
Effect on Mount & Update
Whenever the values in the dependency array change, the effect is re-run.
Effect Cleanup
React will call your cleanup function each time before the effect runs again, and one final time when the component unmounts (gets removed).
Unmount
After Update & Unmount
Behavior inside
- components will re-render an extra time to find bugs caused by impure rendering
- components will re-run effects an extra time to find bugs caused by missing cleanup