I'm trying to figure out width update value of item in nested array of reducer and change value.
Its my reducer state:
let initialState = {
data: {
users: [
{
id: 1,
name: 'a'
},
{
id: 2,
name: 'b'
}
]
}
}
and I want to change name of item in data.users but I can't access there
How can I do this?
I tried this
case SET_NAME:
return {
...state,
users: state.data.users((item, i) =>
item.id == action.payload.id ? { ...item, value: action.payload.value} : null
)
};
but I can't access the users