Skip to content

Commit

Permalink
Merge pull request #4035 from reduxjs/create-app-slice
Browse files Browse the repository at this point in the history
Rename "createSliceWithThunks" and "createThunkSlice" to "createAppSlice"
  • Loading branch information
EskiMojo14 committed Jan 3, 2024
2 parents f3748d9 + 0b9fdcc commit ed8282e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
5 changes: 2 additions & 3 deletions docs/api/createSlice.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

:::

Expand Down
4 changes: 2 additions & 2 deletions docs/usage/migrating-rtk-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions packages/toolkit/src/tests/createSlice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -607,7 +607,7 @@ describe('createSlice', () => {
}

test('successful thunk', async () => {
const slice = createThunkSlice({
const slice = createAppSlice({
name: 'test',
initialState: [] as any[],
reducers: (create) => ({
Expand Down Expand Up @@ -650,7 +650,7 @@ describe('createSlice', () => {
})

test('rejected thunk', async () => {
const slice = createThunkSlice({
const slice = createAppSlice({
name: 'test',
initialState: [] as any[],
reducers: (create) => ({
Expand Down Expand Up @@ -694,7 +694,7 @@ describe('createSlice', () => {
})

test('with options', async () => {
const slice = createThunkSlice({
const slice = createAppSlice({
name: 'test',
initialState: [] as any[],
reducers: (create) => ({
Expand Down Expand Up @@ -743,7 +743,7 @@ describe('createSlice', () => {
})

test('has caseReducers for the asyncThunk', async () => {
const slice = createThunkSlice({
const slice = createAppSlice({
name: 'test',
initialState: [],
reducers: (create) => ({
Expand Down

0 comments on commit ed8282e

Please sign in to comment.