Update the addItem to below given function.
const addItem = () => { const newItem = { id: (data.length + 1).toString(), name: `Item ${data.length + 1}` }; setData([...data, ...newItem]); };