Replies: 1 comment 2 replies
-
If I understand correctly, I don't see why you can't nest spread operators to produce the next immutable state? const newData = [
...currentData,
[index] : { ...currentData[index], state: checked },
]; Spread may be shallow, but you can use nesting for deeper state updates. Why not use a library like Immer? You won't regret it. Edit: fixed |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I need to update one of the object in array based on current data
here is my current working code:
I have tried spread clone array and using
map()
,filter()
,reduce()
to update the state but with no success because of spread's shallow clone.are there any better way than using
slice()
andconcat()
and not using any 3rd party lib at all?Beta Was this translation helpful? Give feedback.
All reactions