"Lazy initial state" is actually greedy
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 11.8k
- Forks
- 7.9k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 11
Description
Is there any good reason to call the useState(() => ...) feature "Lazy initial state"? The actual implementation is synchronous ("greedy") as far as I can tell, so I would propose to rename it to "Functional initial state" (for consistency with "Functional updates").
- docs: https://reactjs.org/docs/hooks-reference.html#lazy-initial-state
- implementation: https://github.com/facebook/react/blob/02da938fd51f6345ca185d571ea6628189ae81a7/packages/react-reconciler/src/ReactFiberHooks.new.js#L1135-L1142
Related "Lazy initialization" in useReducer section => I would propose "Initialization function"
- docs: https://reactjs.org/docs/hooks-reference.html#lazy-initialization
- implementation: https://github.com/facebook/react/blob/02da938fd51f6345ca185d571ea6628189ae81a7/packages/react-reconciler/src/ReactFiberHooks.new.js#L646-L657
I can make a PR unless someone points out some aspect of the naming that I missed.
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 with the Hooks reference sections linked in the issue: “lazy initial state” and “lazy initialization.” Compare their terminology with the referenced ReactFiberHooks.new.js implementation and the “Functional updates” wording. Done means the documentation terminology is reviewed and any agreed naming is applied consistently in both sections.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100