**只有當出現一串一樣的元素的時候**?,這個時候 Virtual DOM 去 reconciliate(搞) DOM 的時候會傻傻分不清楚。
> 別的時候不要用 key,key 已經出現在 virtual dom diff/reconciliation 的階段,效率要更低于 shouldComponentUpdate,所以盡量通過 shouldComponentUpdate 來決定是否要 render component。

官網文檔的這個例子
~~~
renderA: <div><span>first</span></div>
renderB: <div><span>second</span><span>first</span></div>
=> [replaceAttribute textContent 'second'], [insertNode <span>first</span>]
~~~
其實是往第一個位置插入了一個 span,但是會被 diff 成
* 替換內容 first 到 second
* 插入內容為 first 的 span
不光是這樣會更慢的問題,如果你在 first 上綁有事件的話,重新 render 后因為是 replace 了內容,因此這是原來的事件會變成 second 的事件,這樣就?**完全錯亂**?了。
- 1. Why not 2 way binding/為毛不用雙向綁定
- 2. What's Virtual DOM, why should we care / 為毛要用 Vitual Dom
- 3. Why Immutable / 為毛要不可變
- 4. How to do Unit test React project / 如何單元測試
- 5. Modular and Components
- 6. How should I thinking in react way / 如何以 React 的方式解決問題
- 7. What about Data Fetching / 只有 V 的話,數據 M 呢
- 8. What about Router / router 怎么辦
- 9. How to communicate between two components that don't have a parent-child relationship/ 不是父子關系的 component 怎么交互
- 10. When should I use "key" / 什么時候該用 key
- 11. What's these Warnings / 這些黃黃的是神馬
- 12. How to Profile Component Perfomance / 如何提升效率