Skip to content

Commit 9c30868

Browse files
Merge pull request #331 from zeroLR/patch-1
2 parents 566e910 + 3c8c752 commit 9c30868

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

content/docs/lists-and-keys.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const todoItems = todos.map((todo, index) =>
119119
);
120120
```
121121

122-
我們並不建議你使用索引作為 key,尤其如果項目的順序會改變的話。這會對效能產生不好的影響,也可能會讓 component state 產生問題。請參考 Robin Pokorny 這篇[深入剖析使用索引作為 key 的負面效應](ttps://robinpokorny.com/blog/index-as-a-key-is-an-anti-pattern/)ㄧ文。如果你選擇不明確分配 key 到列表項目時,React 預設將會使用索引作為 key。
122+
我們並不建議你使用索引作為 key,尤其如果項目的順序會改變的話。這會對效能產生不好的影響,也可能會讓 component state 產生問題。請參考 Robin Pokorny 這篇[深入剖析使用索引作為 key 的負面效應](https://robinpokorny.com/blog/index-as-a-key-is-an-anti-pattern/)ㄧ文。如果你選擇不明確分配 key 到列表項目時,React 預設將會使用索引作為 key。
123123

124124
如果你想了解更多,請參考[深度剖析 key 的必要性](/docs/reconciliation.html#recursing-on-children)一文。
125125

0 commit comments

Comments
 (0)