Skip to content

Instantly share code, notes, and snippets.

@gnzandrs
Created November 27, 2018 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnzandrs/0322fcc8da69ee2d8da0294f38b0b28e to your computer and use it in GitHub Desktop.
Save gnzandrs/0322fcc8da69ee2d8da0294f38b0b28e to your computer and use it in GitHub Desktop.
react key atribute example for medium
// forma incorrecta
render() {
return (
<div>
{(
this.state.usuarios.map((id, index) => {
return <Usuario
key = {index}
id = {id}
/>
})
)}
</div>
)
}
// forma correcta
render() {
return (
<div>
{(
this.state.usuarios.map((id, index) => {
return <Usuario
key = {id} // utilizamos el id unico como key
id = {id}
/>
})
)}
</div>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment