-
Notifications
You must be signed in to change notification settings - Fork 47.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix: useDeferredValue loop during popstate transition #27559
Conversation
Adds a regression test where an unstable value passed to useDeferredValue value during a popstate transition can lead to an infinite render loop.
During a popstate event, we attempt to render updates synchronously even if they are transitions, to preserve scroll position if possible. We do this by entangling the transition lane with the Sync lane. However, if rendering the transition spawns additional transition updates (e.g. a setState inside useEffect), there's no reason to render those synchronously, too. We should use the normal transition behavior. This fixes an issue where useDeferredValue during a popstate event would spawn a transition update that was itself also synchronous.
Comparing: f172fa7...c9f5737 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) |
What if you update two roots in one popstate? |
meh it just won’t preserve scroll position |
We could support that but I think to do it properly we'd need to track either |
During a popstate event, we attempt to render updates synchronously even if they are transitions, to preserve scroll position if possible. We do this by entangling the transition lane with the Sync lane. However, if rendering the transition spawns additional transition updates (e.g. a setState inside useEffect), there's no reason to render those synchronously, too. We should use the normal transition behavior. This fixes an issue where useDeferredValue during a popstate event would spawn a transition update that was itself also synchronous. DiffTrain build for [6db7f42](6db7f42)
React upstream changes: - facebook/react#27570 - facebook/react#27569 - facebook/react#27550 - facebook/react#27559 - facebook/react#27552 - facebook/react#27504 - facebook/react#27522 Co-authored-by: Josh Story <[email protected]>
) During a popstate event, we attempt to render updates synchronously even if they are transitions, to preserve scroll position if possible. We do this by entangling the transition lane with the Sync lane. However, if rendering the transition spawns additional transition updates (e.g. a setState inside useEffect), there's no reason to render those synchronously, too. We should use the normal transition behavior. This fixes an issue where useDeferredValue during a popstate event would spawn a transition update that was itself also synchronous.
During a popstate event, we attempt to render updates synchronously even if they are transitions, to preserve scroll position if possible. We do this by entangling the transition lane with the Sync lane. However, if rendering the transition spawns additional transition updates (e.g. a setState inside useEffect), there's no reason to render those synchronously, too. We should use the normal transition behavior. This fixes an issue where useDeferredValue during a popstate event would spawn a transition update that was itself also synchronous. DiffTrain build for commit 6db7f42.
During a popstate event, we attempt to render updates synchronously even if they are transitions, to preserve scroll position if possible. We do this by entangling the transition lane with the Sync lane.
However, if rendering the transition spawns additional transition updates (e.g. a setState inside useEffect), there's no reason to render those synchronously, too. We should use the normal transition behavior.
This fixes an issue where useDeferredValue during a popstate event would spawn a transition update that was itself also synchronous.