Skip to content

Commit 27b0aa1

Browse files
committed
fix error==undefined case, reduce diff
1 parent 63bfbae commit 27b0aa1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/createAsyncThunk.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,24 +92,24 @@ export function createAsyncThunk<
9292
meta: {
9393
args,
9494
requestId,
95-
...(error.name === 'AbortError' && {
96-
aborted: true,
97-
abortReason: error.message
98-
})
95+
...(error &&
96+
error.name === 'AbortError' && {
97+
aborted: true,
98+
abortReason: error.message
99+
})
99100
}
100101
}
101102
}
102103
)
103104

104105
function actionCreator(args: ActionParams) {
105-
const abortController = new AbortController()
106-
107-
return function thunkAction(
106+
return (
108107
dispatch: TA['dispatch'],
109108
getState: TA['getState'],
110109
extra: TA['extra']
111-
) {
110+
) => {
112111
const requestId = nanoid()
112+
const abortController = new AbortController()
113113
let abortAction: ReturnType<typeof rejected> | undefined
114114

115115
function abort(reason: string = 'Aborted.') {

0 commit comments

Comments
 (0)