I have an issue with updating the immutable redux and quite nested data. Here's an example of my data structure and what I want to change. If anyone could show me the pattern of accessing this update using ES6 and spread operator I would be thankful.
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
This is a longer solution but might help you as your redux state grows. I've also changed some of the values in the original state to make a clearer explanation.
This should do the trick, assuming the data is set up exactly as shown, with the given array indices:
If index of the element to be changed is to be determined dynamically, you'll need to use functionality such as
filter
to find and remove the array element you're updating, and then spread the corresponding subarrays by editing the structure of the call toslice
.Try using Immutability Helper
I think in your structure, like this
I've tried it Click Me