jeffcarp / frontend-hyperpolyglot

The same operations in React, Angular 1&2, Ember, Polymer, Vue, and Riot
http://jeffcarp.github.io/frontend-hyperpolyglot
MIT License
269 stars 22 forks source link

Add key attribute in React repeat example #11

Closed just-boris closed 8 years ago

just-boris commented 8 years ago

While other frameworks can take care about repeating items, React requires special key attribute. There is a section in React documentation about this.

Unless you do it, you will get a warning from React in developer mode.

jeffcarp commented 8 years ago

Thank you @just-boris! I've heard that using index makes the diffing algorithm less efficient, do you think it would make sense to make it items.map(item => <div key={index.id}></div>)?

just-boris commented 8 years ago

@jeffcarp Updated PR.

This is okay for me. My goal is showing that key always necessary in React, rather than other frameworks

jeffcarp commented 8 years ago

Excellent, thanks for the contribution @just-boris 👍 🎉