const data = [
{
title: 'Todo',
items: ['do home work', 'complete study'],
},
{
title: 'In-Progress',
items: ['learn tailwind', 'build some projects'],
},
{
title: 'Completed',
items: ['completed work'],
},
];
const [list, setList] = useState(data);
const [text, setText] = useState('');
This addItem function adding a new copy of Todo every time when I add an item. How can I add the item to the todo without adding a new copy
const addItem = () => {
setList((prev) => {
return [
(prev[0] = {
...prev[0],
items: [text, ...prev[0].items],
}),
...prev,
];
});
setText('');
};
addItem = (text, todoId).