DEV Community

Discussion on: Run useEffect Only Once :React

Collapse
 
lexlohr profile image
Alex Lohr

Also if you only want to run it on unmount, you can use

useEffect(() => onUnmountHandler, [])
Enter fullscreen mode Exit fullscreen mode

onUnmountHandler will then be called after the component unmounts.