"Lazy initial state" is actually greedy
未關閉
還沒有人認領這個 Issue。
- 主要語言
- JavaScript
- 星號
- 11.8k
- 分支
- 7.9k
- 平均合併
- 1 天 11 小時
- 30 天內合併 PR
- 11
描述
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.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 issue 中連結的 Hooks 參考部分開始:「lazy initial state」和「lazy initialization」。將它們的術語與所參照的實作 ReactFiberHooks.new.js 以及「Functional updates」的措辭進行比較。完成的標準是審查文件術語,並在兩個部分中一致地套用任何已達成共識的命名。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- javascript, react
- 領域
- documentation
- Issue 類型
- 文件
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100