Skip to content
Myr

chore: fix links, fixes #779

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Michel Weststrate · committed by Michel Weststrate · parent a98b655 · Browse files · 8 files+37 added−33 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

8 files+37 added−33 removed

  • other:+37 added−33 removed

8 files+37 added−33 removed

modified:website/docs/api.md+19 added-19 removed
modified:website/docs/faq.md+1 added-1 removed
modified:website/docs/installation.mdx+2 added-2 removed
29 unmodified lines
3031| Feature | Description | Method to call |32| --- | --- | --- |33| ES 5 support | If your application needs to be able to run on older JavaScript environments, such as Internet Explorer or React Native, enable this feature. | `enableES5()` |34| [ES2015 Map and Set support](complex-objects) | To enable Immer to operate on the native `Map` and `Set` collections, enable this feature | `enableMapSet()` |35| [JSON Patch support](patches) | Immer can keep track of all the changes you make to draft objects. This can be useful for communicating changes using JSON patches | `enablePatches()` |34| [ES2015 Map and Set support](./complex-objects.md) | To enable Immer to operate on the native `Map` and `Set` collections, enable this feature | `enableMapSet()` |35| [JSON Patch support](./patches.mdx) | Immer can keep track of all the changes you make to draft objects. This can be useful for communicating changes using JSON patches | `enablePatches()` |36| **All of the above** | Unsure what features you need? We recommend to enable all of the features above by default on new projects. Premature optimization of a few KB might not be worth the initial trouble. Also, enabling or disabling features doesn't impact the performance of Immer itself | `enableAllPlugins()` |3738For example, if you want to use `produce` on a `Map`, you need to enable this feature once during the start of your application:39
43 unmodified lines
modified:website/docs/introduction.md+1 added-1 removed
modified:website/docs/map-set.md+1 added-1 removed
5 unmodified lines
6<center>7<div data-ea-publisher="immerjs" data-ea-type="image" class="horizontal bordered"></div>8</center>910_⚠ Since version 6 support for `Map`s and `Set`s has to be enabled explicitly by calling [`enableMapSet()`](installation#pick-your-immer-version) once when starting your application._10_⚠ Since version 6 support for `Map`s and `Set`s has to be enabled explicitly by calling [`enableMapSet()`](./installation.mdx#pick-your-immer-version) once when starting your application._1112Plain objects, arrays, `Map`s and `Set`s are always drafted by Immer. An example of using Maps with immer:1314```javascript
46 unmodified lines
modified:website/docs/patches.mdx+7 added-4 removed
7 unmodified lines
8 data-ea-publisher="immerjs"9 data-ea-type="image"10 className="horizontal bordered"11 ></div>12</center> <details>12</center>13<details>14 <summary className="egghead-summary">15 egghead.io lesson 14: Capture patches using _produceWithPatches_16 </summary>17 <br />
10 unmodified lines
28 href="https://egghead.io/lessons/react-capture-patches-to-distribute-changes-in-app-state-with-immer-producewithpatches"29 >30 Hosted on egghead.io31 </a>31</details> <details>32</details>33<details>34 <summary className="egghead-summary">35 egghead.io lesson 16: Apply Patches using _applyPatches_36 </summary>37 <br />
12 unmodified lines
50 Hosted on egghead.io51 </a>52</details>5352_⚠ Since version 6 support for Patches has to be enabled explicitly by calling [`enablePatches()`](installation#pick-your-immer-version) once when starting your application._54_⚠ Since version 6 support for Patches has to be enabled explicitly by calling [`enablePatches()`](./installation.mdx#pick-your-immer-version) once when starting your application._5556During the run of a producer, Immer can record all the patches that would replay the changes made by the reducer. This is a very powerful tool if you want to fork your state temporarily and replay the changes to the original.5758Patches are useful in few scenarios:
101 unmodified lines
160 href="https://egghead.io/lessons/react-use-immer-inversepatches-to-build-undo-functionality"161 >162 Hosted on egghead.io163 </a>162</details> <details>164</details>165<details>166 <summary className="egghead-summary">167 egghead.io lesson 20: Use patches to build redo functionality168 </summary>169 <br />
58 unmodified lines
modified:website/docs/pitfalls.md+3 added-3 removed
7 unmodified lines
8</center>910### Performance tips1112For performance tips, see [Performance Tips](https://immerjs.github.io/immer/docs/performance/#performance-tips).12For performance tips, see [Performance Tips](./performance.mdx#performance-tips).1314### Don't reassign the recipe argument1516Never reassign the `draft` argument (example: `draft = myCoolNewState`). Instead, either modify the `draft` or return a new state. See [Returning data from producers](https://immerjs.github.io/immer/docs/return).16Never reassign the `draft` argument (example: `draft = myCoolNewState`). Instead, either modify the `draft` or return a new state. See [Returning data from producers](./return.mdx).1718### Immer only supports unidirectional trees1920Immer assumes your state to be a unidirectional tree. That is, no object should appear twice in the tree, there should be no circular references. There should be exactly one path from the root to any node of the tree.
7 unmodified lines
28Immer [does not support exotic objects](https://github.com/immerjs/immer/issues/504) such as window.location.2930### Classes should be made draftable or not mutated3132You will need to enable your own classes to work properly with Immer. For docs on the topic, check out the section on [working with complex objects](https://immerjs.github.io/immer/docs/complex-objects).32You will need to enable your own classes to work properly with Immer. For docs on the topic, check out the section on [working with complex objects](./complex-objects.md).3334### Only valid indices and length can be mutated on Arrays3536For arrays, only numeric properties and the `length` property can be mutated. Custom properties are not preserved on arrays.
53 unmodified lines
modified:website/docs/produce.mdx+3 added-2 removed
7 unmodified lines
8 data-ea-publisher="immerjs"9 data-ea-type="image"10 className="horizontal bordered"11 ></div>12</center> <details>12</center>13<details>14 <summary className="egghead-summary">15 egghead.io lesson 3: Simplifying deep updates with _produce_16 </summary>17 <br />
16 unmodified lines
34The Immer package exposes a default function that does all the work.3536`produce(currentState, producer: (draftState) => void): nextState`3737There is also a curried overload that is explained [in a later section](curried-produce).38There is also a curried overload that is explained [in a later section](./curried-produce.mdx).3940## Example4142```javascript
36 unmodified lines