React — Handling Side Effects with useEffect
Side effects include things like fetching data, manipulating the DOM, or setting timers. React’s useEffect
hook lets you handle these effects safely.
useEffect(() => {
console.log('Component mounted');
return () => {
console.log('Component unmounted');
};
}, []);