Last active
February 10, 2017 12:43
-
-
Save kenmori/48ff70932fa7d650a7cd0132873f749c to your computer and use it in GitHub Desktop.
keyを持つコードとkeyを持たないコード【React】これ。Warning: flattenChildren(...): Encountered two children with the same key, `keyName`. Child keys must be unique; when two children share a key, only the first child will be used.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////no key////////keyを持たないで返しているコード/// | |
const users = this.state.users.map(function (user){ | |
return <User id={user.id} name={user.name} />; | |
}); | |
////////add key//////keyを設定して返しているコード/// | |
const users = this.state.users.map(function (user){ | |
return <User id={user.id} key={user.id} name={user.name} />; | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment