I have the following data :
removed_users = [1]
And
userProfile = [{id:1 , user:{id:1,username:test}} ,
{id:2 , user:{id:2,username:test2}} ,]
What i wish to do:
I wish to be able to remove the correct objects from userProfile , based on the array removed_users . I have tried the following code below but its not removing it from the array
state.project['userProfile'].filter(function(user) {
return !action.payload.find(function(removed) {
return removed === user.user.id
})
})}
This is the code for the reducer thats supposed to help me remove the removed_users from the state
case 'user_remove': return (updateObject(state, {
project: {...state.project , ['users']: state.project['userProfile'].filter(function(user) {
return !action.payload.find(function(removed) {
return removed === user.user.id
})
})}
}))
This is the script for updateObject helper function:
export const updateObject = (oldObject, updatedProperties) => {
return {
...oldObject,
...updatedProperties
}
}