Skip to content

Commit

Permalink
fix(useAsyncFn): fix TS type definition error
Browse files Browse the repository at this point in the history
  • Loading branch information
vikiboss committed Oct 11, 2024
1 parent 5c8b71b commit ccd107e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/react-use/src/use-async-fn/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export interface UseAsyncFnOptions<T extends AnyFunc, D = Awaited<ReturnType<T>>
*
* @defaultValue undefined
*/
onError?: (error: E | undefined) => void
onError?: (error: E | undefined, params: Parameters<T> | []) => void
/**
* a function to run before the async function
*
Expand Down
4 changes: 2 additions & 2 deletions packages/react-use/src/use-async-fn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export interface UseAsyncFnOptions<T extends AnyFunc, D = Awaited<ReturnType<T>>
*
* @since 1.4.0
*/
onError?: (error: E | undefined) => void
onError?: (error: E | undefined, params: Parameters<T> | []) => void
/**
* a function to run before the async function
*
Expand Down Expand Up @@ -236,7 +236,7 @@ export function useAsyncFn<T extends AnyFunc, D = Awaited<ReturnType<T>>, E = an
})
} catch (error) {
runVersionedAction(version, () => {
latest.current.onError?.(error as E | undefined)
latest.current.onError?.(error as E | undefined, stateRef.params.value)
actions.updateRefState('error', error as E | undefined)
})
} finally {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-use/src/use-async-fn/index.zh-cn.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export interface UseAsyncFnOptions<T extends AnyFunc, D = Awaited<ReturnType<T>>
*
* @defaultValue undefined
*/
onError?: (error: E | undefined) => void
onError?: (error: E | undefined, params: Parameters<T> | []) => void
/**
* 运行异步函数之前的函数
*
Expand Down

0 comments on commit ccd107e

Please sign in to comment.