Using the array index
suggest changeIf you don’t have unique database ids at hand, you could also use the numeric index of your array like this:
render() {
const { todos } = this.props;
return (
<ul>
{ todos.map((todo, index) =>
<li key={ `todo-${index}` }>
{ todo.text }
</li>
}
</ul>
);
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents