Skip to content

Commit 1890c54

Browse files
committed
update error message
1 parent 1cf1601 commit 1890c54

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

errors.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@
3333
"31": "\"middleware\" field must be a callback",
3434
"32": "When using custom hooks for context, all hooks need to be provided: .\\nHook was either not provided or not a function.",
3535
"33": "Existing Redux context detected. If you already have a store set up, please use the traditional Redux setup.",
36-
"34": "selectSlice returned undefined for an uninjected slice reducer"
36+
"34": "selectSlice returned undefined for an uninjected slice reducer",
37+
"35": "Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`."
3738
}

packages/toolkit/src/createSlice.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,8 @@ function handleThunkCaseReducerDefinition<State>(
899899
) {
900900
if (!cAT) {
901901
throw new Error(
902-
'Cannot use create.asyncThunk without custom initialisation'
902+
'Cannot use `create.asyncThunk` in the built-in `createSlice`. ' +
903+
'Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`.'
903904
)
904905
}
905906
const { payloadCreator, fulfilled, pending, rejected, settled, options } =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ describe('createSlice', () => {
580580
initialState: [] as any[],
581581
reducers: (create) => ({ thunk: create.asyncThunk(() => {}) }),
582582
})
583-
).toThrowErrorMatchingInlineSnapshot('"Cannot use create.asyncThunk without custom initialisation"')
583+
).toThrowErrorMatchingInlineSnapshot('"Cannot use `create.asyncThunk` in the built-in `createSlice`. Use `buildCreateSlice({ creators: { asyncThunk: asyncThunkCreator } })` to create a customised version of `createSlice`."')
584584
})
585585
const createThunkSlice = buildCreateSlice({
586586
creators: { asyncThunk: asyncThunkCreator },

0 commit comments

Comments
 (0)