Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Bug: Infinite rendering resulting in freezing of tab/browser | GoodFirstPicks

Bug: Infinite rendering resulting in freezing of tab/browser

facebook/react 20 comments 1mo ago
View on GitHub
highopenScope: somewhat clearSkill match: noReactJavaScriptTypeScript

Why this is a good first issue

Proposes fundamental changes to React's dependency comparison mechanism which would require deep framework knowledge.

AI Summary

The issue reports infinite rendering when objects/arrays are used in useEffect dependencies due to reference comparison. It suggests either adding deep comparison functionality or better error detection. This would require core React changes with significant architectural implications and potential performance tradeoffs.

Issue Description

React is not preventing infinite rendering/looping and results in freezing of browser.

The root cause of this issue is because the dependency array of useEffect compares object/array by reference. But, this is a serious issue because

  • This is a common trap people might get into because of dynamic nature of Javascript, and people might not know the thing they are passing to dependency array is a primitive value or an array/object.
  • React should catch this infinite rendering and throw a helpful error. This error is already thrown by React for some of the cases. But, clearly React does not catch this for all the cases.
  • The documentation of useEffect does not have a single reference to this gotcha - guarding against passing object/array to the dependency array, since reference of the object/array is being checked, not a deep comparison value. Some solutions already exist like https://github.com/kentcdodds/use-deep-compare-effect, https://stackoverflow.com/questions/54095994/react-useeffect-comparing-objects/63965274#63965274. But, only people who are aware of this behaviour of useEffect will reach out to these solutions (or they might manually deep compare with their own custom hook as some people do in the linked stackoverflow link)

It would also be helpful if useEffect includes a helpful option like

useEffect(() => {
 // myArray, myObject gets new reference on evey render
}, [myArray, myObject], {
   deepCompare: true/false // it would be helpful to have this instead of reaching for custom hooks/npm packages
})

React version: 16.12.x (any latest version)

Steps To Reproduce

  1. Click the codesandbox link - https://codesandbox.io/s/apollo-client-uselazyquery-example-forke

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 10 points when you complete it!

Risk Flags

  • core React behavior change
  • potential performance impact
  • backwards compatibility concerns
Loading labels...

Details

Points10 pts
Difficultyhigh
Scopesomewhat clear
Skill Matchno
Test Focusedno