Skip to content
Myr

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

2 files+8 added−7 removed

modified:src/types/index.js.flow+4 added-4 removed
26 unmodified lines
27 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 lines
49 <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 lines
modified:website/docs/example-reducer.mdx+4 added-3 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 13: Using Immer in a (React) reducer16 </summary>17 <br />
15 unmodified lines
3334Here is a simple example of the difference that Immer could make in practice.3536```javascript36// Reducer with inital state37// Reducer with initial state38const INITIAL_STATE = {}39// Shortened, based on: https://github.com/reactjs/redux/blob/master/examples/shopping-cart/src/reducers/products.js40const byId = (state = INITIAL_STATE, action) => {41 switch (action.type) {
15 unmodified lines
5758```javascript59import produce from "immer"6060// Reducer with inital state61// Reducer with initial state62const INITIAL_STATE = {}6364const byId = produce((draft, action) => {65 switch (action.type) {
13 unmodified lines