@@ -56,7 +56,7 @@ function useAsync<T extends {}>(
56
56
const counter = useRef ( 0 )
57
57
const isMounted = useRef ( true )
58
58
const lastArgs = useRef < any [ ] | undefined > ( undefined )
59
- const lastOptions = useRef < AsyncOptions < T > | undefined > ( undefined )
59
+ const lastOptions = useRef < AsyncOptions < T > > ( options )
60
60
const lastPromise = useRef < Promise < T > | undefined > ( undefined )
61
61
const abortController = useRef < AbortController > ( new MockAbortController ( ) )
62
62
@@ -157,7 +157,7 @@ function useAsync<T extends {}>(
157
157
. then ( handleResolve ( counter . current ) )
158
158
. catch ( handleReject ( counter . current ) )
159
159
} else if ( promiseFn && ! isPreInitialized ) {
160
- start ( ( ) => promiseFn ( lastOptions . current ! , abortController . current ) )
160
+ start ( ( ) => promiseFn ( lastOptions . current , abortController . current ) )
161
161
. then ( handleResolve ( counter . current ) )
162
162
. catch ( handleReject ( counter . current ) )
163
163
}
@@ -168,7 +168,7 @@ function useAsync<T extends {}>(
168
168
( ...args ) => {
169
169
if ( deferFn ) {
170
170
lastArgs . current = args
171
- start ( ( ) => deferFn ( args , lastOptions . current ! , abortController . current ) )
171
+ start ( ( ) => deferFn ( args , lastOptions . current , abortController . current ) )
172
172
. then ( handleResolve ( counter . current ) )
173
173
. catch ( handleReject ( counter . current ) )
174
174
}
0 commit comments