Skip to content

Commit

Permalink
chore: fix links, fixes #779
Browse files Browse the repository at this point in the history
  • Loading branch information
mweststrate committed Apr 10, 2021
1 parent a98b655 commit bc35916
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 33 deletions.
38 changes: 19 additions & 19 deletions website/docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,30 @@ title: API overview

| Exported name | Description | Section |
| --- | --- | --- |
| `(default)` | The core API of Immer, typically named `produce`: `import produce from "immer"` | [Produce](produce) |
| `applyPatches` | Given a base state or draft, and a set of patches, applies the patches | [Patches](patches) |
| `castDraft` | Converts any immutable type to its mutable counterpart. This is just a cast and doesn't actually do anything. | [TypeScript](typescript) |
| `castImmutable` | Converts any mutable type to its immutable counterpart. This is just a cast and doesn't actually do anything. | [TypeScript](typescript) |
| `createDraft` | Given a base state, creates a mutable draft for which any modifications will be recorded | [Async](async) |
| `current` | Given a draft object (doesn't have to be a tree root), takes a snapshot of the current state of the draft | [Current](current) |
| `Draft<T>` | Exposed TypeScript type to convert an immutable type to a mutable type | [TypeScript](typescript) |
| `enableAllPlugins()` | Enables all plugins mentioned below | [Installation](installation#pick-your-immer-version) |
| `enableES5()` | Enables support for older JavaScript engines, such as Internet Explorer and React Native | [Installation](installation#pick-your-immer-version) |
| `enableMapSet()` | Enables support for `Map` and `Set` collections. | [Installation](installation#pick-your-immer-version) |
| `enablePatches()` | Enables support for JSON patches. | [Installation](installation#pick-your-immer-version) |
| `finishDraft` | Given an draft created using `createDraft`, seals the draft and produces and returns the next immutable state that captures all the changes | [Async](async) |
| `(default)` | The core API of Immer, typically named `produce`: `import produce from "immer"` | [Produce](./produce.mdx) |
| `applyPatches` | Given a base state or draft, and a set of patches, applies the patches | [Patches](./patches.mdx) |
| `castDraft` | Converts any immutable type to its mutable counterpart. This is just a cast and doesn't actually do anything. | [TypeScript](./typescript.mdx) |
| `castImmutable` | Converts any mutable type to its immutable counterpart. This is just a cast and doesn't actually do anything. | [TypeScript](./typescript.mdx) |
| `createDraft` | Given a base state, creates a mutable draft for which any modifications will be recorded | [Async](./async.mdx) |
| `current` | Given a draft object (doesn't have to be a tree root), takes a snapshot of the current state of the draft | [Current](./current.md) |
| `Draft<T>` | Exposed TypeScript type to convert an immutable type to a mutable type | [TypeScript](./typescript.mdx) |
| `enableAllPlugins()` | Enables all plugins mentioned below | [Installation](./installation.mdx#pick-your-immer-version) |
| `enableES5()` | Enables support for older JavaScript engines, such as Internet Explorer and React Native | [Installation](./installation.mdx#pick-your-immer-version) |
| `enableMapSet()` | Enables support for `Map` and `Set` collections. | [Installation](./installation.mdx#pick-your-immer-version) |
| `enablePatches()` | Enables support for JSON patches. | [Installation](./installation#pick-your-immer-version) |
| `finishDraft` | Given an draft created using `createDraft`, seals the draft and produces and returns the next immutable state that captures all the changes | [Async](./async.mdx) |
| `freeze(obj, deep?)` | Freezes draftable objects. Returns the original object. By default freezes shallowly, but if the second argument is `true` it will freeze recursively. |
| `Immer` | constructor that can be used to create a second "immer" instance (exposing all APIs listed in this instance), that doesn't share its settings with global instance. |
| `immerable` | Symbol that can be added to a constructor or prototype, to indicate that Immer should treat the class as something that can be safely drafted | [Classes](complex-objects) |
| `immerable` | Symbol that can be added to a constructor or prototype, to indicate that Immer should treat the class as something that can be safely drafted | [Classes](./complex-objects.md) |
| `Immutable<T>` | Exposed TypeScript type to convert mutable types to immutable types | |
| `isDraft` | Returns true if the given object is a draft object | |
| `isDraftable` | Returns true if Immer is capable of turning this object into a draft. Which is true for: arrays, objects without prototype, objects with `Object` as their prototype, objects that have the `immerable` symbol on their constructor or prototype | |
| `nothing` | Value that can be returned from a recipe, to indicate that the value `undefined` should be produced | [Return](return) |
| `original` | Given a draft object (doesn't have to be a tree root), returns the original object at the same path in the original state tree, if present | [Original](original) |
| `Patch` | Exposed TypeScript type, describes the shape of an (inverse) patch object | [Patches](patches) |
| `produce` | The core API of Immer, also exposed as the `default` export | [Produce](produce) |
| `produceWithPatches` | Works the same as `produce`, but instead of just returning the produced object, it returns a tuple, consisting of `[result, patches, inversePatches]`. | [Patches](patches) |
| `setAutoFreeze` | Enables / disables automatic freezing of the trees produces. By default enabled. | [Freezing](freezing) |
| `nothing` | Value that can be returned from a recipe, to indicate that the value `undefined` should be produced | [Return](./return.mdx) |
| `original` | Given a draft object (doesn't have to be a tree root), returns the original object at the same path in the original state tree, if present | [Original](./original.md) |
| `Patch` | Exposed TypeScript type, describes the shape of an (inverse) patch object | [Patches](./patches.mdx) |
| `produce` | The core API of Immer, also exposed as the `default` export | [Produce](./produce.mdx) |
| `produceWithPatches` | Works the same as `produce`, but instead of just returning the produced object, it returns a tuple, consisting of `[result, patches, inversePatches]`. | [Patches](./patches.mdx) |
| `setAutoFreeze` | Enables / disables automatic freezing of the trees produces. By default enabled. | [Freezing](./freezing.mdx) |
| `setUseProxies` | Can be used to disable or force the use of `Proxy` objects. Useful when filing bug reports. | |

## Importing immer
Expand Down
2 changes: 1 addition & 1 deletion website/docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ A: Yes

## Q: I can't rely on Proxies being present on my target environments. Can I use Immer?

A: Yes - [view details](installation#immer-on-older-javascript-environments)
A: Yes - [view details](./installation.mdx#immer-on-older-javascript-environments)

## Q: Can I typecheck my data structures when using Immer?

Expand Down
4 changes: 2 additions & 2 deletions website/docs/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ The following features can be opt-in to:
| Feature | Description | Method to call |
| --- | --- | --- |
| 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()` |
| [ES2015 Map and Set support](complex-objects) | To enable Immer to operate on the native `Map` and `Set` collections, enable this feature | `enableMapSet()` |
| [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()` |
| [ES2015 Map and Set support](./complex-objects.md) | To enable Immer to operate on the native `Map` and `Set` collections, enable this feature | `enableMapSet()` |
| [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()` |
| **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()` |

For example, if you want to use `produce` on a `Map`, you need to enable this feature once during the start of your application:
Expand Down
2 changes: 1 addition & 1 deletion website/docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const nextState = produce(baseState, draftState => {

The interesting thing about Immer is that the `baseState` will be untouched, but the `nextState` will be a new immutable tree that reflects all changes made to `draftState` (and structurally sharing the things that weren't changed).

Head to the [next section](produce) to further dive into `produce`.
Head to the [next section](./produce.mdx) to further dive into `produce`.

## Benefits

Expand Down
2 changes: 1 addition & 1 deletion website/docs/map-set.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: Map and Set
<div data-ea-publisher="immerjs" data-ea-type="image" class="horizontal bordered"></div>
</center>

_⚠ 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._
_⚠ 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._

Plain objects, arrays, `Map`s and `Set`s are always drafted by Immer. An example of using Maps with immer:

Expand Down
11 changes: 7 additions & 4 deletions website/docs/patches.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ title: Patches
data-ea-type="image"
className="horizontal bordered"
></div>
</center> <details>
</center>
<details>
<summary className="egghead-summary">
egghead.io lesson 14: Capture patches using _produceWithPatches_
</summary>
Expand All @@ -28,7 +29,8 @@ title: Patches
>
Hosted on egghead.io
</a>
</details> <details>
</details>
<details>
<summary className="egghead-summary">
egghead.io lesson 16: Apply Patches using _applyPatches_
</summary>
Expand All @@ -49,7 +51,7 @@ title: Patches
</a>
</details>

_⚠ Since version 6 support for Patches has to be enabled explicitly by calling [`enablePatches()`](installation#pick-your-immer-version) once when starting your application._
_⚠ 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._

During 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.

Expand Down Expand Up @@ -159,7 +161,8 @@ The generated patches are similar (but not the same) to the [RFC-6902 JSON patch
>
Hosted on egghead.io
</a>
</details> <details>
</details>
<details>
<summary className="egghead-summary">
egghead.io lesson 20: Use patches to build redo functionality
</summary>
Expand Down
6 changes: 3 additions & 3 deletions website/docs/pitfalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ title: Pitfalls

### Performance tips

For performance tips, see [Performance Tips](https://immerjs.github.io/immer/docs/performance/#performance-tips).
For performance tips, see [Performance Tips](./performance.mdx#performance-tips).

### Don't reassign the recipe argument

Never 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).
Never reassign the `draft` argument (example: `draft = myCoolNewState`). Instead, either modify the `draft` or return a new state. See [Returning data from producers](./return.mdx).

### Immer only supports unidirectional trees

Expand All @@ -29,7 +29,7 @@ Immer [does not support exotic objects](https://github.com/immerjs/immer/issues/

### Classes should be made draftable or not mutated

You 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).
You 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).

### Only valid indices and length can be mutated on Arrays

Expand Down
5 changes: 3 additions & 2 deletions website/docs/produce.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ title: Using produce
data-ea-type="image"
className="horizontal bordered"
></div>
</center> <details>
</center>
<details>
<summary className="egghead-summary">
egghead.io lesson 3: Simplifying deep updates with _produce_
</summary>
Expand All @@ -34,7 +35,7 @@ The Immer package exposes a default function that does all the work.

`produce(currentState, producer: (draftState) => void): nextState`

There is also a curried overload that is explained [in a later section](curried-produce).
There is also a curried overload that is explained [in a later section](./curried-produce.mdx).

## Example

Expand Down

0 comments on commit bc35916

Please sign in to comment.