This is a more of a can it ever be done even with a parser like babel or anything type of question which i believe is allowed in SU. All just to make my code cleaner for Reducer and State in general; what I want to do is:
return {
...state,
myObj: {
...state.myObj,
items: [
...state.myObj.items,
[index]: newValue, // do something like this
]
}
}
Anyone know how we can do this cleanly? I dont want to use a slice()
or just do newState.myObj.items[index] = newValue
as that messy and difficult to read as per other SU answers. Maybe I'm the only one that OCD about clean reducer states, without using a library. Anyone have come across this pattern or how one may achieve it? Id be happy to install a bebel plugin but cant seem to find one.
Thanks