[Question] How to updated deeply nested array elements? #767
Replies: 3 comments
-
Hi, In my case I had nested state just like you which was bein updated (CRUD operation) dynamically. I have used Example:
There might be a better way to do this stuff but this got me work done for me :) as I am very new to React in fact my first ever project and I had to deal with state management, thanks to this amazing library it suited well in my case. Let me know if this works for you as well or how can this be improved :) |
Beta Was this translation helpful? Give feedback.
-
FYI, updating large state trees via Immer can have a negative effect on performance. Sometimes it is better to do a standard immutable update like in a traditional Redux reducer. There is discussion around introducing this capability within here. It would be great to get your feedback. |
Beta Was this translation helpful? Give feedback.
-
I had a similar issues where i found myself updating deeply nested entities and this is how i solved it 1 - breaking down our entities into individual objects that can be referenced, this was done using normalizr
2 - Create a separate reducer where our objects will live
3 - Write/read objects using the entity reducer
|
Beta Was this translation helpful? Give feedback.
-
What's the best practices around deep state trees? I've got a tree that resembles the following:
Whenever I update a specific child, I perform a breadth-first search to get the element and then update with an action:
The main issue that I'm having is that I have this
mergeElements
function which has to figure out how to deeply merge sinceObject.assign
doesn't do deep merges. Since easy-peasy is using Immer under the hood, I was wondering if there's a better approach to this?Beta Was this translation helpful? Give feedback.
All reactions