DEV Community

Discussion on: Cheat Sheet for Updating Objects and Arrays in React State

Collapse
 
jakeborromeo profile image
Jake Borromeo

In this snippet, the 'id' property is in brackets. Is this React syntax or some type of destructuring?

const handleAdd = (todo) => {
setTodos({...todos, [todo.id]: todo});
}