Question · JavaScript and React course · Module 5: useEffect and Custom Hooks
Object in Dependency Array
Why can placing an object directly in the useEffect dependency array cause an infinite loop?
Answer options
- Objects are not supported as dependencies in useEffect
- React compares dependencies by reference, and a new object created on each render has a different reference
- Objects are too large for React to compare
- useEffect does not support deep equality comparison
You can check the correct answer by solving this task in the CodeWorlds game.