Skip to content

Commit 1d98748

Browse files
blurrahmarkerikson
authored andcommitted
Fix CreateReducr typo in createReducer() docs (#75)
1 parent b1bdb97 commit 1d98748

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/api/createReducer.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ This approach works well, but is a bit boilerplate-y and error-prone. For instan
2929
The `createReducer` helper streamlines the implementation of such reducers. It takes two arguments. The first one is the initial state. The second is an object mapping from action types to _case reducers_, each of which handles one specific action type.
3030

3131
```js
32-
const counterReducer = createReducr(0, {
32+
const counterReducer = createReducer(0, {
3333
increment: (state, action) => state + action.payload,
3434
decrement: (state, action) => state - action.payload
3535
})
@@ -41,7 +41,7 @@ If you created action creators using `createAction()`, you can use those directl
4141
const increment = createAction('increment')
4242
const decrement = createAction('decrement')
4343

44-
const counterReducer = createReducr(0, {
44+
const counterReducer = createReducer(0, {
4545
[increment]: (state, action) => state + action.payload,
4646
[decrement]: (state, action) => state - action.payload
4747
})
@@ -55,7 +55,7 @@ Redux requires reducer functions to be pure and treat state values as immutable.
5555
const addTodo = createAction('todos/add')
5656
const toggleTodo = createAction('todos/toggle')
5757

58-
const todosReducer = createReducr([], {
58+
const todosReducer = createReducer([], {
5959
[addTodo]: (state, action) => {
6060
const todo = action.payload
6161
return [...state, todo]
@@ -80,7 +80,7 @@ To make things easier, `createReducer` uses [immer](https://github.com/mweststra
8080
const addTodo = createAction('todos/add')
8181
const toggleTodo = createAction('todos/toggle')
8282

83-
const todosReducer = createReducr([], {
83+
const todosReducer = createReducer([], {
8484
[addTodo]: (state, action) => {
8585
// This push() operation gets translated into the same
8686
// extended-array creation as in the previous example.
@@ -99,7 +99,7 @@ const todosReducer = createReducr([], {
9999
If you choose to write reducers in this style, make sure to learn about the [pitfalls mentioned in the immer docs](https://github.com/mweststrate/immer#pitfalls) . Most importantly, you need to ensure that you either mutate the `state` argument or return a new state, _but not both_. For example, the following reducer would throw an exception if a `toggleTodo` action is passed:
100100

101101
```js
102-
const todosReducer = createReducr([], {
102+
const todosReducer = createReducer([], {
103103
[toggleTodo]: (state, action) => {
104104
const index = action.payload
105105
const todo = state[index]

0 commit comments

Comments
 (0)