DEV Community

Discussion on: React - useEffect hook - A Quick Guide

Collapse
 
joeattardi profile image
Joe Attardi

useEffect is not quite equivalent to componentDidMount, it's a different mental model. See this article for a good explanation.

It's also worth noting that the cleanup from useEffect is not only run when the component is unmounted, but also every time the effect runs again when a dependency changes, the cleanup function returned by the previous effect will be run.

Collapse
 
josec profile image
Jose C

Hi Joe, thanks for sharing this react training post certainly my explanation about the useEffect and it's class methods equivalents it's not the best so I unpublished this post to fix it. 🙂