Last active
August 11, 2017 00:13
-
-
Save treyhuffine/0287b093c482c56121e99ad96e91a075 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function ListItem(props) { | |
// Correct! There is no need to specify the key here: | |
return <li>{props.value}</li>; | |
} | |
function UserList(props) { | |
const users = props.users; | |
const listItems = users.map((user) => | |
// Correct! Key should be specified inside the array. | |
<ListItem key={user.id.toString()} | |
value={user.name} /> | |
); | |
return ( | |
<ul> | |
{listItems} | |
</ul> | |
); | |
} | |
const users = [ | |
{id: 1, name: 'Khaleesi'} , | |
{id: 2, name: 'Jon'}, | |
{id: 3, name: 'Arya'} | |
]; | |
<UserList users={users} /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment