How to use `componentWillUnmount()` with `useEffect()`?

useEffect(() => {
  return () => {
    console.log('unmount')
  }
}, [])
Copy

September 9th, 2019

# componentWillUnmount() as hook

Add to bookmarks

The returned function inside useEffect() will be called before the component is removed from the UI.

Tracking with Matomo to improve the UX. See Privacy Policy for more details.