[Suggestion]: render function should be idempotent, not strictly pure
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 11.8k
- Forks
- 7.9k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 11
Description
Summary
React docs explain in many instances that render should be pure and you should not read or update refs for this reason, because some features like Suspense can interrupt rendering and restart it.
But from my understanding render can be impure, what matters is that render must be idempotent, meaning interrupting render and calling it again with the same props will always return the same result. The exception given in the docs (using a ref for initialization) works because it is idempotent.
There are many other idempotent but not pure use cases, for example the implementation of what was called useEvent makes use of refs during render but should be fine.
Page
https://react.dev/reference/react/useRef#referencing-a-value-with-a-ref
Details
Change wording of pure to idempotent.
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 at the linked React useRef reference page and review the explanations of render purity and ref initialization. Change the relevant wording from “pure” to “idempotent,” then verify that the page accurately describes the requirement for interrupted and repeated renders.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100