reactjs / reactjs/react.dev

[Bug]:Possible wrong descrption for useDeferredValue

Open
#8,324 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug: unconfirmed
Dominant language
JavaScript
Stars
11.8k
Forks
7.9k
Avg merge
1d 11h
Merged PRs (30d)
11

Description

Summary

The doucmention describe the wrong behaviour for useDeferredValue

Page

https://react.dev/reference/react/Suspense

Details

The documentation says:

The query will update immediately, so the input will display the new value. However, the deferredQuery will keep its previous value until the data has loaded

From my test, deferredQuery also updates immediately rather than waiting for the data to be loaded here is the link https://codesandbox.io/p/sandbox/react-dev-forked-kxfktt

Image

useDeferredValue consistently lags query with around 4 or 5 ms

Think about it, if deferredQuery updates after SearchResults is ready, how SearchResults receive the latest data at the first place?

The real reason we can see opacity: 0.2 for several seconds is that the new content is not rendered yet; rather than

the deferredQuery will keep its previous value until the data has loaded

If my understanding is correct, I should say the documentation is misleading, especially for the newbies

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the useDeferredValue passage on https://react.dev/reference/react/Suspense and reproduce the behavior in the linked CodeSandbox. Compare the wording about deferredQuery with the observed timing, then update the documentation so it accurately explains when the value changes and what the opacity indicates.

Written by the indexing model from the issue text.

Assessment

Tech stack
react
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.