Incorrect sentence in `useSyncExternalStore`
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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