We have some todo list. We have initialState kind of of like...
initialState = [ {
id: 0,
title: "first",
items: [
{
title: "one from first",
id: 0,
cards: [
{
id: 0,
text: "111",
},
{
id: 1,
text: "222",
},
],
},
{
title: "two from first",
id: 1,
cards: [
{
id: 0,
text: "www",
},
{
id: 1,
text: "zzz",
},
],
},
], }, {
id: 1,
title: "second board",
items: [
{
title: "first from second",
id: 0,
cards: [
{
id: 0,
text: "asd",
},
{
id: 1,
text: "fasdf",
},
],
},
], }, ];
We wont normalize this state for some reasons. I have to add new List. The reducer here:
switch(action) {
case CONSTANTS.ADD_LIST:
const newList = {
title: action.payload.title,
cards: [],
id: listID,
};
listID += 1;
return {
...state,
[action.payload.boardID]: {
...state[action.payload.boardID],
items: [...state[action.payload.boardID].items, newList],
},
};
}
Example. I want to add newList for items from board 1(starting from 0).
I tested another examples like the above and it's useless.
So I can't get why it's not working. I think I have some problems with docs redux and I can't get it.
Thanks!