I can successfully do the following which allows me to build an object of profiles with userid's as the key - I like this structure as it helps with other parts of the application
function profilesMembersResponseConcat(members, newMember) {
members[newMember.userid] = newMember
return members
}
[C.PROFILES_MEMBERS_RESPONSE]: (state, { payload }) => ({
...state,
profilesMembersResponse: profilesMembersResponseConcat(state.profilesMembersResponse, payload)
}),
Question: Is there a way however to do this without the need for a function. I've tried below but I get an error message: "Arrow function should not return assignment."
[C.PROFILES_MEMBERS_RESPONSE]: (state, { payload }) => ({
...state,
profilesMembersResponse: state.profilesMembersResponse[payload.userid] = payload
}),