Skip to content

Commit a71639a

Browse files
gjastrabmarkerikson
authored andcommitted
Correct log output when introing createSlice (#225)
Initial example block demonstrating `createSlice` didn't include type including the slice's name as the prefix. Also fix missing tilde before block.
1 parent 60c5ced commit a71639a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/usage/usage-guide.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ That simplifies things because we don't need to have multiple files, and we can
439439

440440
To simplify this process, Redux Starter Kit includes a `createSlice` function that will auto-generate the action types and action creators for you, based on the names of the reducer functions you provide.
441441

442-
Here's how that posts example would look with `createSlice:
442+
Here's how that posts example would look with `createSlice`:
443443

444444
```js
445445
const postsSlice = createSlice({
@@ -468,10 +468,10 @@ console.log(postsSlice)
468468
const { createPost } = postsSlice.actions
469469

470470
console.log(createPost({ id: 123, title: 'Hello World' }))
471-
// {type : "createPost", payload : {id : 123, title : "Hello World"}}
471+
// {type : "posts/createPost", payload : {id : 123, title : "Hello World"}}
472472
```
473473

474-
`createSlice` looked at all of the functions that were defined in the `reducers` field, and for every "case reducer" function provided, generates an action creator that uses the name of the reducer as the action type itself. So, the `createPost` reducer became an action type of `"createPost"`, and the `createPost()` action creator will return an action with that type.
474+
`createSlice` looked at all of the functions that were defined in the `reducers` field, and for every "case reducer" function provided, generates an action creator that uses the name of the reducer as the action type itself. So, the `createPost` reducer became an action type of `"posts/createPost"`, and the `createPost()` action creator will return an action with that type.
475475

476476
```js
477477
const postsSlice = createSlice({

0 commit comments

Comments
 (0)