how to add loading state to true in 'addItem' (reducer case), and set the loading state to false?
But I'm stuck using react-hook https://codesandbox.io/s/new-water-vczdp
I did it here: https://codesandbox.io/s/react-todolist-3dko3 with older react version.
What to do here?
case "addItem": {
//fakeHttp();
const { toAddItem, items } = state;
const nextId = +items[items.length - 1].id + 1;
return {
items: [...items, { id: nextId, name: toAddItem }],
loading: false
};
}