Skip to content

Commit ed8282e

Browse files
authored
Merge pull request #4035 from reduxjs/create-app-slice
Rename "createSliceWithThunks" and "createThunkSlice" to "createAppSlice"
2 parents f3748d9 + 0b9fdcc commit ed8282e

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

docs/api/createSlice.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,12 @@ Instead, import `buildCreateSlice` and `asyncThunkCreator`, and create your own
251251
```ts
252252
import { buildCreateSlice, asyncThunkCreator } from '@reduxjs/toolkit'
253253
254-
// name is up to you
255-
export const createSliceWithThunks = buildCreateSlice({
254+
export const createAppSlice = buildCreateSlice({
256255
creators: { asyncThunk: asyncThunkCreator },
257256
})
258257
```
259258

260-
Then import this `createSlice` as needed instead of the exported version from RTK.
259+
Then import this `createAppSlice` as needed instead of the exported version from RTK.
261260

262261
:::
263262

docs/usage/migrating-rtk-2.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,11 +657,11 @@ In practice, we hope these are reasonable tradeoffs. Creating thunks inside of `
657657
Here's what the new callback syntax looks like:
658658

659659
```ts
660-
const createSliceWithThunks = buildCreateSlice({
660+
const createAppSlice = buildCreateSlice({
661661
creators: { asyncThunk: asyncThunkCreator },
662662
})
663663

664-
const todosSlice = createSliceWithThunks({
664+
const todosSlice = createAppSlice({
665665
name: 'todos',
666666
initialState: {
667667
loading: false,

packages/toolkit/src/tests/createSlice.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ describe('createSlice', () => {
590590
'"Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`."'
591591
)
592592
})
593-
const createThunkSlice = buildCreateSlice({
593+
const createAppSlice = buildCreateSlice({
594594
creators: { asyncThunk: asyncThunkCreator },
595595
})
596596
function pending(state: any[], action: any) {
@@ -607,7 +607,7 @@ describe('createSlice', () => {
607607
}
608608

609609
test('successful thunk', async () => {
610-
const slice = createThunkSlice({
610+
const slice = createAppSlice({
611611
name: 'test',
612612
initialState: [] as any[],
613613
reducers: (create) => ({
@@ -650,7 +650,7 @@ describe('createSlice', () => {
650650
})
651651

652652
test('rejected thunk', async () => {
653-
const slice = createThunkSlice({
653+
const slice = createAppSlice({
654654
name: 'test',
655655
initialState: [] as any[],
656656
reducers: (create) => ({
@@ -694,7 +694,7 @@ describe('createSlice', () => {
694694
})
695695

696696
test('with options', async () => {
697-
const slice = createThunkSlice({
697+
const slice = createAppSlice({
698698
name: 'test',
699699
initialState: [] as any[],
700700
reducers: (create) => ({
@@ -743,7 +743,7 @@ describe('createSlice', () => {
743743
})
744744

745745
test('has caseReducers for the asyncThunk', async () => {
746-
const slice = createThunkSlice({
746+
const slice = createAppSlice({
747747
name: 'test',
748748
initialState: [],
749749
reducers: (create) => ({

0 commit comments

Comments
 (0)