score:3

Accepted answer

You can use the map function to replace the item :

handleDuplicate = (id, nextId) => {
  const currentItem = this.state.items[id];
  const items = this.state.items.map(
    item => item.id === nextId ? currentItem : item
  );

  this.setState(prevState => ({items});
}

Related Query

More Query from same tag