question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useDeferredValue does not abort running reconcile work for stale value

See original GitHub issue

Do you want to request a feature or report a bug? bug

What is the current behavior? When useDeferredValue value is updated while the previous reconcile work is still running, The previous reconcile work is not aborted, and the new work is queued after it.

repro: Based on useDeferredValue example, https://codesandbox.io/s/infallible-dewdney-9fkv9

For better reproducibility i’ve made it to run longer using using timeoutMs: 30000 + while (performance.now() - now < 100) { ) and i’ve added an indicator value: Time since last key stroke https://codesandbox.io/s/intelligent-mestorf-u0p2b

  • Start timeline record
  • Type A B C with 1-3 sec interval between key strokes.
  • See timeline, there’s work of 24 secs 8 + 8 + 8, for each key stroke
  • See the values of Result #X changes to the old stale value.

This is not optimal for 2 reasons:

  • We show stale data when we have something newer.
  • The cpu is locked processing the old value reconcile, and the new value needs to wait.

What is the expected behavior? The prev reconcile work should be cancelled/aborted, And the new value reconcile should start immediately

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

react/react-dom 0.0.0-experimental-5faf377df

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:11
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
gaearoncommented, Nov 9, 2019

This is probably a bug, same as the issue where multiple startTransitions don’t always use the latest. Let’s track it here.

4reactions
gaearoncommented, Jul 25, 2020

There’s pretty major ongoing refactors that might end up addressing this. But no promises on the timing. We’ve slipped enough times that I would just say it’s ready when it’s ready. I think we’ll want to fix this before the stable release but it is still a while away.

Read more comments on GitHub >

github_iconTop Results From Across the Web

useDeferredValue does not abort running reconcile work for stale ...
What is the current behavior? When useDeferredValue value is updated while the previous reconcile work is still running, The previous reconcile work is...
Read more >
useDeferredValue - React Docs
If the background update caused by a new value suspends the UI, the user will not see the fallback. They will keep seeing...
Read more >
React 18 Concurrent Mode: How transitions really work (feat ...
Reconcile that JSX into the existing HTML; Run effects in the updates components. Especially the two middle steps can be quite time-consuming, ...
Read more >
useDeferredValue Hook Explained - Web Dev Simplified Blog
React 18 recently had its official non-beta release and with it came ... In this article I will help explain how this hook...
Read more >
Solid.js feels like what I always wanted React to be
I always advice aspiring react devs to understand why this exact setInterval() doesn't work (and why there is the need for the rule-of-hooks), ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found