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

Bug: useDeferredValue with a value that is new every render hangs browser #19925

Closed
chriserickson opened this issue Sep 29, 2020 · 4 comments
Closed

Comments

@chriserickson
Copy link

React version: 0.0.0-experimental-94c0244ba

Steps To Reproduce

Attempt to load the following component:

export default function Component() {
  const value = { something: "I'm new every render" };
  const deferredValue = React.unstable_useDeferredValue(value, {
     timeoutMs: 3000
  });
  console.log("Component render");
  return (
    <div>{deferredValue}</div>
  );
}

The above (buggy) component will peg the CPU and hang the browser. While this is understandable (there are theoretically infinite concurrent trees), it is an easy pitfall for someone to fall into.

Not sure if this could be identified by a console warning or lint rule.

The current behavior

Browser hangs.

The expected behavior

A lint rule informs me of my error or the console warns me that the deferred value changes every render.

@chriserickson chriserickson added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Sep 29, 2020
@gaearon gaearon added Component: Concurrent Features Type: Needs Investigation and removed Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug labels Sep 30, 2020
@gaearon
Copy link
Collaborator

gaearon commented Mar 30, 2022

Just to update — this is still how it works today. We think we might have a strategy that can avoid this in the future, but not for the 18 release.

@gaearon
Copy link
Collaborator

gaearon commented Apr 1, 2022

#24247

@gaearon
Copy link
Collaborator

gaearon commented Apr 11, 2022

Hmmm. This is very strange but I can't reproduce this even with the original version and example that you added. And the new PR is meant to address this case further. I think we can close this, but if it's still reproducible with the @next builds, let me know.

@gaearon gaearon closed this as completed Apr 11, 2022
@gaearon
Copy link
Collaborator

gaearon commented Apr 27, 2022

18.1.0 should include the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants