Skip to content

Commit 44cd3b1

Browse files
authored
Merge pull request #3869 from PaoloDiBello/docs/create-slice-configureStore
Update store configuration using configureStore in createSlice.mdx
2 parents 7536b8b + 694c877 commit 44cd3b1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/api/createSlice.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,9 @@ Result's function `getInitialState` provides access to the initial state value g
233233
## Examples
234234

235235
```ts
236-
import { createSlice, createAction } from '@reduxjs/toolkit'
236+
import { createSlice, createAction, configureStore } from '@reduxjs/toolkit'
237237
import type { PayloadAction } from '@reduxjs/toolkit'
238-
import { createStore, combineReducers } from 'redux'
238+
import { combineReducers } from 'redux'
239239
240240
const incrementBy = createAction<number>('incrementBy')
241241
const decrementBy = createAction<number>('decrementBy')
@@ -282,13 +282,13 @@ const user = createSlice({
282282
},
283283
})
284284
285-
const reducer = combineReducers({
286-
counter: counter.reducer,
287-
user: user.reducer,
285+
const store = configureStore({
286+
reducer: {
287+
counter: counter.reducer,
288+
user: user.reducer,
289+
},
288290
})
289291
290-
const store = createStore(reducer)
291-
292292
store.dispatch(counter.actions.increment())
293293
// -> { counter: 1, user: {name : '', age: 21} }
294294
store.dispatch(counter.actions.increment())

0 commit comments

Comments
 (0)