reactjs / reactjs/react.dev

Examples for generating 'Stable, Predictable and Unique' keys

未關閉
#3,536 1 則留言 3 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
JavaScript
星號
11.8k
分支
7.9k
平均合併
1 天 11 小時
30 天內合併 PR
11

描述

Reconciliation chapter spends a good time explaining why using the index or even Math.random() as a key is a bad idea, proceeding to suggest using an existent id as a key. When there's not an existent id, it's suggested to "add a new ID property to your model or hash some parts of the content to generate a key".

That's a very controversial issue, a lot of people do it wrong. An example of how to do it would make the chapter a lot better. It's an extensive chapter (compared to others) that seems to end up with no code conclusion. 

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

先閱讀 Reconciliation 章節的「Recursing On Children」部分,以及關於產生唯一 key 的連結討論。為沒有現有 id 的模型確定一個清楚且技術上可靠的範例,然後使用該範例和說明更新該章節;當指南在不依賴不穩定 key 的情況下涵蓋常見陷阱時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
javascript, react
領域
documentation
Issue 類型
文件
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。