DEV Community

Discussion on: Setting state for parent from within useEffect hook in child component causes an infinite loop

Collapse
 
roggc profile image
roggc • Edited

Either if you don't pass state as a prop you still get an infinite loop. I think when parent component re-renders, child component unmount and mounts, so is, as you say, componentDidMount, so that's why useEffect code always executes.