I want to dynamically pass the id of the entry I want to remove with the payload into the reducer and I am trying to delete an object property (the one with the "eowvw698x" id which is dynamical and may change) and preserve the existing ones.
case DELETE_ENTRY:
return {
...state,
diaryEntries: {
...state.diaryEntries,
??????
},
};
How can I achieve this?
Edit
I've used Vencovsky's answer and Klaycon's comment suggestion and wrote:
case DELETE_ENTRY:
const { [payload]: dontcare, ...otherProperties } = state.diaryEntries;
return {
...state,
diaryEntries: {
...otherProperties,
},
};
The solutions of other people mutated the state object, which is forbidden by the Supreme Algorithm.