Comments (1)
Actually, the differed value is not changing immediately. It is working as stated in the docs.
React will first attempt a re-render with the old value (so it will return the old value), and then try another re-render in background with the new value (so it will return the updated value).
In your example everything is working right as described in docs. There are not many operations happening in background in your example so after the first render with an old value the engine immediately performs another background re-render and after finishing the first render you see an old value and almost immediately a new deferred one as the next re-render happens.
You can have a look at my code sample. Please, open the console and pay attention to isStale, query, deferredQuery
variables. When console shows isStale
as true it means that the value of variable is being differed at the moment you can see values of each variable in console log at every moment of code execution.
from react.
Related Issues (20)
- Bug: 'Warning: validateDOMNesting: <hr> cannot appear as a child of <select>' – but this is now valid HTML HOT 2
- Bug: Nested components imported with React.lazy cause rerendering HOT 1
- Bug: React.memo fails to memoize component HOT 1
- UseEffect only works on localhost but not in production HOT 3
- [DevTools Bug]: React Dev Tools break gstreamer docs HOT 2
- Bug: hoisted stylesheets should not reorder when re-rendered in a transition
- Bug: exhaustive-deps lint should allow omitting unchanging values HOT 1
- Ability to turn off ‘Download DevTools’ console message HOT 3
- What does the community think of the war between Israel and Palestine? Will it donate to Palestine? HOT 5
- The left Sidebar is not scrolling on small Displays HOT 1
- Bug: React 18 Suspense with unstable value would trigger multiple rerenders
- Bug: flushSync on component having useLayoutEffect in some cases causes Maximum update depth exceeded HOT 1
- Bug: Stale values returned from useOptimistic when state changes
- Bug: Re-rendering nested components breaks event listeners on parent HOT 3
- Bug: contentEditable attribute does not allow the 'plaintext-only' value HOT 3
- Bug: manipulating controlled input value breaks native validation HOT 4
- Sponsored issue: fix an issue
- Bug: Re-rendering nested components breaks event listeners on parent HOT 1
- Bug: Nested suspense boundaries `Cannot read properties of null (reading 'parentNode')` on resolution
- Bug: pending attribute from useFormStatus is stuck as "true" when form action takes longer than ~5s to resolve HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react.