TLDR Web Dev · ARTICLES & TUTORIALS
REACT INTERNALS: WHICH USEEFFECT RUNS FIRST?
Summary from the TLDR Web Dev newsletter
In React, parent components render before children, but children's useEffect hooks run before their parents'. This happens because React uses a DFS algorithm during its commit phase, walking up the component tree from the deepest nodes to the shallowest. Understanding this can help avoid subtle bugs in complex component hierarchies, especially when effects in parent components might depend on changes made by child components.