I'm trying to update the objects that is in the nested array, below is an example of my state. I am trying to update the objects within goals I succeed with updating the objects.
BUT
Each time I update any object. the object at index 0, will get a copy of all the objects. And the more times I update, it creates more copies and they become nested within the object at index 0.
The object at index 0 will also be updated with the most recent update of any object.
{
list: {
'0': {
id: 0,
dueDate: 'By May 28th I Will have: ',
goals: [
{
0: {...}
1: {...}
3: {...}
}
]
}
'1':{
id: 0,
dueDate: 'By June 31st I Will have: ',
goals: [
{
2: {...}
4: {...}
}
}
keyName = index of object in list. ( the two ones above '0' and '1' : { )
Reducer
return {
...state,
[action.payload.keyName]: {
...state[action.payload.keyName],
goals: [
{ ...state[action.payload.keyName].goals, ...action.payload.goal },
...state[action.payload.keyName].goals.slice(1, state[action.payload.keyName].goals.length)
]
}
};
Also if you know any good documentation or tutorial on normalizr please let me know.
Thank you in advance! :)