使用陣列索引

如果你手頭沒有唯一的資料庫 ID,你還可以使用陣列的數字索引,如下所示:

render() {
  const { todos } = this.props;
  return (
    <ul>
      { todos.map((todo, index) =>
        <li key={ `todo-${index}` }>
          { todo.text }
        </li>
      }
    </ul>
  );
}