Skip to content
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

Fix infinite update loop that happens when an unmemoized value is passed to useDeferredValue #24247

Merged
merged 2 commits into from Apr 11, 2022

Commits on Apr 11, 2022

  1. Fix infinite loop if unmemoized val passed to uDV

    The current implementation of useDeferredValue will spawn a new
    render any time the input value is different from the previous one. So
    if you pass an unmemoized value (like an inline object), it will never
    stop spawning new renders.
    
    The fix is to only defer during an urgent render. If we're already
    inside a transition, retry, offscreen, or other non-urgen render, then
    we can use the latest value.
    acdlite committed Apr 11, 2022
    Copy the full SHA
    422d102 View commit details
    Browse the repository at this point in the history
  2. Temporarily disable "long nested update" warning

    DevTools' timeline profiler warns if an update inside a layout effect
    results in an expensive re-render. However, it misattributes renders
    that are spawned from a sync render at lower priority. This affects the
    new implementation of useDeferredValue but it would also apply to things
    like Offscreen.
    
    It's not obvious to me how to fix this given how DevTools models the
    idea of a "nested update" so I'm disabling the warning for now to
    unblock the bugfix for useDeferredValue.
    acdlite committed Apr 11, 2022
    Copy the full SHA
    e4fd270 View commit details
    Browse the repository at this point in the history