Functional components have no componentWillUnmount. Return a cleanup function from useEffect instead. With an empty dependency array, the effect runs once on mount and the cleanup runs once on unmount.
useEffect(() => {
return () => {
// Anything in here is fired on component unmount.
};
}, []);