diff --git a/docs/api/createSlice.mdx b/docs/api/createSlice.mdx index 53b01a1e4a..45786f3d51 100644 --- a/docs/api/createSlice.mdx +++ b/docs/api/createSlice.mdx @@ -251,13 +251,12 @@ Instead, import `buildCreateSlice` and `asyncThunkCreator`, and create your own ```ts import { buildCreateSlice, asyncThunkCreator } from '@reduxjs/toolkit' -// name is up to you -export const createSliceWithThunks = buildCreateSlice({ +export const createAppSlice = buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator }, }) ``` -Then import this `createSlice` as needed instead of the exported version from RTK. +Then import this `createAppSlice` as needed instead of the exported version from RTK. ::: diff --git a/docs/usage/migrating-rtk-2.md b/docs/usage/migrating-rtk-2.md index deacc89922..b537ec9d41 100644 --- a/docs/usage/migrating-rtk-2.md +++ b/docs/usage/migrating-rtk-2.md @@ -657,11 +657,11 @@ In practice, we hope these are reasonable tradeoffs. Creating thunks inside of ` Here's what the new callback syntax looks like: ```ts -const createSliceWithThunks = buildCreateSlice({ +const createAppSlice = buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator }, }) -const todosSlice = createSliceWithThunks({ +const todosSlice = createAppSlice({ name: 'todos', initialState: { loading: false, diff --git a/packages/toolkit/src/tests/createSlice.test.ts b/packages/toolkit/src/tests/createSlice.test.ts index 6540464d28..d71bcc2f25 100644 --- a/packages/toolkit/src/tests/createSlice.test.ts +++ b/packages/toolkit/src/tests/createSlice.test.ts @@ -590,7 +590,7 @@ describe('createSlice', () => { '"Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`."' ) }) - const createThunkSlice = buildCreateSlice({ + const createAppSlice = buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator }, }) function pending(state: any[], action: any) { @@ -607,7 +607,7 @@ describe('createSlice', () => { } test('successful thunk', async () => { - const slice = createThunkSlice({ + const slice = createAppSlice({ name: 'test', initialState: [] as any[], reducers: (create) => ({ @@ -650,7 +650,7 @@ describe('createSlice', () => { }) test('rejected thunk', async () => { - const slice = createThunkSlice({ + const slice = createAppSlice({ name: 'test', initialState: [] as any[], reducers: (create) => ({ @@ -694,7 +694,7 @@ describe('createSlice', () => { }) test('with options', async () => { - const slice = createThunkSlice({ + const slice = createAppSlice({ name: 'test', initialState: [] as any[], reducers: (create) => ({ @@ -743,7 +743,7 @@ describe('createSlice', () => { }) test('has caseReducers for the asyncThunk', async () => { - const slice = createThunkSlice({ + const slice = createAppSlice({ name: 'test', initialState: [], reducers: (create) => ({