When rendering a list what is a key and what is it's purpose? code example
Example 1: react component key prop
function ListItem(props) {
function NumberList(props) {
const numbers = props.numbers;
const listItems = numbers.map((number) =>
return (
<ul>
{listItems}
</ul>
);
}
const numbers = [1, 2, 3, 4, 5];
ReactDOM.render(
<NumberList numbers={numbers} />,
document.getElementById('root')
);
Example 2: When rendering a list what is a key and what is it's purpose?
ReactDOM.render(
<ul>{listItems}</ul>, document.getElementById('root')
);