reactjs – Keys in react – Using the array index

If 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>
  );
}

if you want to reproduce, please indicate the source:
reactjs – Keys in react – Using the array index - CodeDay