In functional components, what is the equivalent of componentWillUnmount?
In functional components, the cleanup function returned by useEffect is the equivalent of componentWillUnmount. When you return a function from useEffect, React will call this function when the component unmounts. This gives you the opportunity to clean up resources like subscriptions or timers to prevent memory leaks.