Question 4 of 10Pro Only
What problems can arise with useEffect dependencies? How do you avoid infinite loops and missing dependencies?
Sample answer preview
The dependency array tells React when to re-run an effect. It compares each entry to the previous render's value using reference equality, and re-runs if any differ. Almost every useEffect bug comes from that array being wrong in one of two directions.
dependency arrayreference equalitystale closureinfinite loopuseCallbackuseMemo