docs: Merge branch 'pvcresin-patch-1'
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 · parents 42aac95, ec03dd0 · Browse files · 2 files·+8 added−7 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+8 added−7 removed
- other:+8 added−7 removed
Provenance
- Commit
cabcd3d- Tree
4710d8a- Author
Michel Weststrate <mweststrate@gmail.com>- Committer
Michel Weststrate <mweststrate@gmail.com>- Parent 1
42aac95- Parent 2
ec03dd0
2 files changed+8 added−7 removed
modified:src/types/index.js.flow+4 added-4 removed
26 unmodified lines27 currentState: S,28 recipe: (draftState: S) => S | void,29 patchListener?: PatchListener30 ): S;31- // curried invocations with inital state31+ // curried invocations with initial state32 <S: Base, A = void, B = void, C = void>(33 recipe: (draftState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S | void,34 initialState: S35 ): (currentState: S | void, a: A, b: B, c: C, ...extraArgs: any[]) => S;36- // curried invocations without inital state36+ // curried invocations without initial state37 <S: Base, A = void, B = void, C = void>(38 recipe: (draftState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S | void39 ): (currentState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S;40 }8 unmodified lines49 <S: Base>(50 currentState: S,51 recipe: (draftState: S) => S | void52 ): [S, Patch[], Patch[]];53- // curried invocations with inital state53+ // curried invocations with initial state54 <S: Base, A = void, B = void, C = void>(55 recipe: (draftState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S | void,56 initialState: S57 ): (currentState: S | void, a: A, b: B, c: C, ...extraArgs: any[]) => [S, Patch[], Patch[]];58- // curried invocations without inital state58+ // curried invocations without initial state59 <S: Base, A = void, B = void, C = void>(60 recipe: (draftState: S, a: A, b: B, c: C, ...extraArgs: any[]) => S | void61 ): (currentState: S, a: A, b: B, c: C, ...extraArgs: any[]) => [S, Patch[], Patch[]];62 }51 unmodified linesmodified:website/docs/example-reducer.mdx+4 added-3 removed
7 unmodified lines8 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 13: Using Immer in a (React) reducer16 </summary>17 <br />15 unmodified lines33 34 Here is a simple example of the difference that Immer could make in practice.35 36 ```javascript36-// Reducer with inital state37+// Reducer with initial state38 const INITIAL_STATE = {}39 // Shortened, based on: https://github.com/reactjs/redux/blob/master/examples/shopping-cart/src/reducers/products.js40 const byId = (state = INITIAL_STATE, action) => {41 switch (action.type) {15 unmodified lines57 58 ```javascript59 import produce from "immer"60 60-// Reducer with inital state61+// Reducer with initial state62 const INITIAL_STATE = {}63 64 const byId = produce((draft, action) => {65 switch (action.type) {13 unmodified lines