Skip to content

Commit 7bf8b06

Browse files
authored
Clearify merge approach example for updating normalized data (#3785)
1 parent c0c7e50 commit 7bf8b06

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/recipes/structuring-reducers/UpdatingNormalizedData.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ hide_title: true
77

88
# Managing Normalized Data
99

10-
As mentioned in [Normalizing State Shape](./NormalizingStateShape.md), the Normalizr library is frequently used to transform nested response data into a normalized shape suitable for integration into the store. However, that doesn't address the issue of executing further updates to that normalized data as it's being used elsewhere in the application. There are a variety of different approaches that you can use, based on your own preference. We'll use the example of adding a new Comment to a Post.
10+
As mentioned in [Normalizing State Shape](./NormalizingStateShape.md), the Normalizr library is frequently used to transform nested response data into a normalized shape suitable for integration into the store. However, that doesn't address the issue of executing further updates to that normalized data as it's being used elsewhere in the application. There are a variety of different approaches that you can use, based on your own preference. We'll use the example of handling mutations for Comments on a Post.
1111

1212
## Standard Approaches
1313

1414
### Simple Merging
1515

16-
One approach is to merge the contents of the action into the existing state. In this case, we need to do a deep recursive merge, not just a shallow copy. The Lodash `merge` function can handle this for us:
16+
One approach is to merge the contents of the action into the existing state. In this case, we can use deep recursive merge, not just a shallow copy, to allow for actions with partial items to update stored items. The Lodash `merge` function can handle this for us:
1717

1818
```js
1919
import merge from 'lodash/merge'

0 commit comments

Comments
 (0)