this is my State:-
roles =[ {
roleId:"8e8be141-130d-4e5c-82d2-0a642d4b73e1"
name:"HR"
description:"HR of the Company"
isModerator:"N"
},
{
roleId:"8e8be141-130d-4e5c-82d2-0a642d4b73e1"
name:"MR"
description:"MR of the Company"
isModerator:"Y"
}]
this is My reducer:-
on(updateRoleItem, (s, { roleId, item }) => {
let modifiedState = [...s];
modifiedState.map((data) => {
if (data.roleId === roleId) {
data.name = item;
}
})
return modifiedState;
})
);
this is what error I am getting:-
I want to update the name property of role in array of roles. So I am finding the object by roleId and then updating the name but I am getting error. Can Someone help me with the right way of doing it?