mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-24 23:56:51 +00:00
Add feature order cycle guide
This commit is contained in:
@@ -7,12 +7,15 @@ export function useAsync<R>(
|
||||
fn: () => Promise<R | typeof AsyncCancel>,
|
||||
inputs: Inputs = [],
|
||||
initialState: AsyncState<R> = { loading: true },
|
||||
): AsyncState<R> {
|
||||
): AsyncState<R> & { refresh: () => Promise<unknown> } {
|
||||
const [state, callback] = useAsyncFn<R, () => Promise<R | typeof AsyncCancel>>(fn, inputs, initialState)
|
||||
|
||||
useEffect(() => {
|
||||
callback()
|
||||
}, [callback])
|
||||
|
||||
return state
|
||||
return {
|
||||
...state,
|
||||
refresh: callback,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user