Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename "createSliceWithThunks" and "createThunkSlice" to "createAppSlice" #4035

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading