It may allow beginners to taste the sweetness of not following the rules
未關閉
還沒有人認領這個 Issue。
type: documentation
- 主要語言
- JavaScript
- 星號
- 11.8k
- 分支
- 7.9k
- 平均合併
- 1 天 11 小時
- 30 天內合併 PR
- 11
描述
Summary
https://react.dev/learn/queueing-a-series-of-state-updates
The first challenge in this chapter can still work normally even if it is written like this, because it relies on click behavior
async function handleClick() {
setPending(pending + 1);
await delay(3000);
setPending(pending=>pending - 1);
setCompleted(completed=>completed + 1);
}
However, if it is changed to this, it will not work. At this point, we must change setPending(pending + 1) to setPending(pending => pending + 1)
async function handleClick() {
setTimeout(()=> {setPending(pending + 1);}, 1000)
await delay(3000);
setPending(pending=>pending - 1);
setCompleted(completed=>completed + 1);
}
Page
https://react.dev/learn/queueing-a-series-of-state-updates
Details
Perhaps some annotations could be added
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從連結的 queueing-a-series-of-state-updates 頁面開始,檢視第一個挑戰及其 state update 範例。重現 issue 中描述的延遲 setTimeout 變體,然後判斷應在哪裡加入註解來說明 functional updater 形式。當頁面清楚警告這種情況,且挑戰仍然容易理解時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- javascript, react
- 領域
- documentation
- Issue 類型
- 文件
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100