Skip to content
Myr

docs: fix example code formatting (#373)

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

authored by bsky · committed by Alec Larson · parent c8ecbad · Browse files · 1 file+8 added−9 removed
This commit

State

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

Diff stats

1 file+8 added−9 removed

  • other:+8 added−9 removed

1 file+8 added−9 removed

modified:readme.md+8 added-9 removed
197 unmodified lines
198199This mechanism can also nicely be leveraged to further simplify our example reducer:200201```javascript202import produce from 'immer'202import produce from "immer"203204const byId = produce((draft, action) => {205 switch (action.type) {206 case RECEIVE_PRODUCTS:207 action.products.forEach(product => {208 draft[product.id] = product209 })210 return211 })212 }205 switch (action.type) {206 case RECEIVE_PRODUCTS:207 action.products.forEach(product => {208 draft[product.id] = product209 })210 return211 }212})213```214215Note that `state` is now factored out (the created reducer will accept a state, and invoke the bound producer with it).
574 unmodified lines