MCPcopy Create free account
hub / github.com/msgbyte/tailchat / useAsyncRefresh

Function useAsyncRefresh

client/shared/hooks/useAsyncRefresh.ts:5–25  ·  view source on GitHub ↗
(
  fn: T,
  deps: DependencyList = []
)

Source from the content-addressed store, hash-verified

3import { useAsyncFn } from './useAsyncFn';
4
5export function useAsyncRefresh<T extends FunctionReturningPromise>(
6 fn: T,
7 deps: DependencyList = []
8) {
9 const [state, callback] = useAsyncFn(fn, deps, {
10 loading: true,
11 });
12
13 useEffect(() => {
14 callback();
15 }, [callback]);
16
17 const refresh = useCallback(() => {
18 return callback();
19 }, [callback]);
20
21 return {
22 ...state,
23 refresh,
24 };
25}

Callers 4

Invite.tsxFile · 0.85
useOpenAppListFunction · 0.85
index.tsxFile · 0.85
index.tsxFile · 0.85

Calls 2

useAsyncFnFunction · 0.90
callbackFunction · 0.50

Tested by

no test coverage detected