File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ export interface FetchOptions<T> extends AsyncOptions<T> {
33
33
}
34
34
35
35
const noop = ( ) => { }
36
+ class MockAbortController implements AbortController {
37
+ public abort = noop
38
+ readonly signal = { } as AbortSignal
39
+ }
36
40
37
41
function useAsync < T extends { } > ( options : AsyncOptions < T > ) : AsyncState < T >
38
42
function useAsync < T extends { } > ( promiseFn : PromiseFn < T > , options ?: AsyncOptions < T > ) : AsyncState < T >
@@ -54,9 +58,7 @@ function useAsync<T extends {}>(
54
58
const lastArgs = useRef < any [ ] | undefined > ( undefined )
55
59
const lastOptions = useRef < AsyncOptions < T > | undefined > ( undefined )
56
60
const lastPromise = useRef < Promise < T > | undefined > ( undefined )
57
- const abortController = useRef < AbortController > ( {
58
- abort : noop ,
59
- } as any )
61
+ const abortController = useRef < AbortController > ( new MockAbortController ( ) )
60
62
61
63
const { devToolsDispatcher } = globalScope . __REACT_ASYNC__
62
64
const { reducer, dispatcher = devToolsDispatcher } = options
You can’t perform that action at this time.
0 commit comments