News for hackers. Stuff that matters.
Re:Thinking in React Hooks by lilactown on Thursday December 12, 2019 @12:26PM (#21773958)
The function given to useEffect will be fired after a successful _commit_ (aka React actually manipulates the DOM after a render).

Here's a helpful diagram that shows the difference between render and commit phases in terms of the class lifecycle methods: http://projects.wojtekmaj.pl/react-lifecycle-methods-diagram...

So when a render executes useEffect with a callback (and values in its dependency array has changed), it will schedule the callback to be run once React has committed the DOM changes based on the current render.

There are no comments on this comment yet.