Skip to content

Commit

Permalink
docs: some refinements on freezing
Browse files Browse the repository at this point in the history
  • Loading branch information
mweststrate committed Nov 19, 2020
1 parent 51cc8b8 commit 7faa7b4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/performance.md
Expand Up @@ -44,7 +44,7 @@ Most important observation:

### Pre-freeze data

When adding a large data set to the state tree in an Immer producer (for example data received from a JSON endpoint), it is worth to call `freeze(json)` on the root of the data to be added first. This will allow Immer to add the new data to the tree faster, as it will skip _recursively_ freezing it, or searching the new data for any changes (drafts) that might be made.
When adding a large data set to the state tree in an Immer producer (for example data received from a JSON endpoint), it is worth to call `freeze(json)` on the root of the data that is being added first. To _shallowly_ freeze it. This will allow Immer to add the new data to the tree faster, as it will avoid the need to _recursively_ scan and freeze the new data.

### You can always opt-out

Expand Down
2 changes: 1 addition & 1 deletion src/core/immerClass.ts
Expand Up @@ -164,7 +164,7 @@ export class Immer implements ProducersFns {
/**
* Pass true to automatically freeze all copies created by Immer.
*
* By default, auto-freezing is disabled in production.
* By default, auto-freezing is enabled.
*/
setAutoFreeze(value: boolean) {
this.autoFreeze_ = value
Expand Down

0 comments on commit 7faa7b4

Please sign in to comment.