Skip to content

Commit 850aab7

Browse files
committed
set default options
1 parent 825c9ba commit 850aab7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/react-async/src/useAsync.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function useAsync<T extends {}>(
5656
const counter = useRef(0)
5757
const isMounted = useRef(true)
5858
const lastArgs = useRef<any[] | undefined>(undefined)
59-
const lastOptions = useRef<AsyncOptions<T> | undefined>(undefined)
59+
const lastOptions = useRef<AsyncOptions<T>>(options)
6060
const lastPromise = useRef<Promise<T> | undefined>(undefined)
6161
const abortController = useRef<AbortController>(new MockAbortController())
6262

@@ -157,7 +157,7 @@ function useAsync<T extends {}>(
157157
.then(handleResolve(counter.current))
158158
.catch(handleReject(counter.current))
159159
} else if (promiseFn && !isPreInitialized) {
160-
start(() => promiseFn(lastOptions.current!, abortController.current))
160+
start(() => promiseFn(lastOptions.current, abortController.current))
161161
.then(handleResolve(counter.current))
162162
.catch(handleReject(counter.current))
163163
}
@@ -168,7 +168,7 @@ function useAsync<T extends {}>(
168168
(...args) => {
169169
if (deferFn) {
170170
lastArgs.current = args
171-
start(() => deferFn(args, lastOptions.current!, abortController.current))
171+
start(() => deferFn(args, lastOptions.current, abortController.current))
172172
.then(handleResolve(counter.current))
173173
.catch(handleReject(counter.current))
174174
}

0 commit comments

Comments
 (0)