showing results for - "li key attribute"
Emilio
29 Feb 2017
1//A “key” is a special string attribute you need 
2//to include when creating lists of elements.
3
4function NumberList(props) {
5  const numbers = props.numbers;
6  const listItems = numbers.map((number) =>
7    <li key={number.toString()}>      {number}
8    </li>
9  );
10  return (
11    <ul>{listItems}</ul>
12  );
13}
14
15const numbers = [1, 2, 3, 4, 5];
16ReactDOM.render(
17  <NumberList numbers={numbers} />,
18  document.getElementById('root')
19);