reactjs / reactjs/react.dev

Incorrect sentence in `useSyncExternalStore`

Open
#6,249 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The documentation of the subscribe argument of useSyncExternalStore states the following (emphasis mine):

subscribe: A function that takes a single callback argument and subscribes it to the store. When the store changes, it should invoke the provided callback. This will cause the component to re-render. The subscribe function should return a function that cleans up the subscription.

As far as I understand, it is not correct that invoking the callback will cause the component to re-render, it is only if the snapshot also changed that the component will re-render. Otherwise it would make a library like Redux unusable if every connected component re-rendered at every store change.

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

Start from the React documentation section for the subscribe argument of useSyncExternalStore and verify the callback and snapshot behavior described in the issue. Update the inaccurate sentence so it reflects that a re-render depends on the snapshot changing; done when the documentation no longer claims every callback invocation re-renders the component.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.