Skip to content

Commit c2a785c

Browse files
BSKYmarkerikson
authored andcommitted
Rename slice to name and tweaks some examples (#220)
1 parent d981e3d commit c2a785c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/usage/usage-guide.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ Here's how that posts example would look with `createSlice:
443443

444444
```js
445445
const postsSlice = createSlice({
446+
name: 'posts',
446447
initialState: [],
447448
reducers: {
448449
createPost(state, action) {},
@@ -454,6 +455,7 @@ const postsSlice = createSlice({
454455
console.log(postsSlice)
455456
/*
456457
{
458+
name: 'posts',
457459
actions : {
458460
createPost,
459461
updatePost,
@@ -471,11 +473,9 @@ console.log(createPost({ id: 123, title: 'Hello World' }))
471473

472474
`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.
473475

474-
You can also optionally define a `slice` parameter with a string that will be used as the prefix of the action types:
475-
476476
```js
477477
const postsSlice = createSlice({
478-
slice: 'posts',
478+
name: 'posts',
479479
initialState: [],
480480
reducers: {
481481
createPost(state, action) {},
@@ -496,7 +496,7 @@ Most of the time, you'll want to define a slice, and export its action creators
496496

497497
```js
498498
const postsSlice = createSlice({
499-
slice: 'posts',
499+
name: 'posts',
500500
initialState: [],
501501
reducers: {
502502
createPost(state, action) {},

0 commit comments

Comments
 (0)