diff --git a/client/shared/hooks/useAsync.ts b/client/shared/hooks/useAsync.ts index d7cca6ac..8ea514d4 100644 --- a/client/shared/hooks/useAsync.ts +++ b/client/shared/hooks/useAsync.ts @@ -1,4 +1,4 @@ -import { DependencyList, useEffect } from 'react'; +import { DependencyList, useEffect, useRef } from 'react'; import type { FunctionReturningPromise } from '../types'; import { useAsyncFn } from './useAsyncFn'; @@ -11,8 +11,17 @@ export function useAsync( const [state, callback] = useAsyncFn(fn, deps, { loading: true, }); + const lockRef = useRef(false); useEffect(() => { + if (lockRef.current === true) { + return; + } + + if (deps.length === 0) { + lockRef.current = true; + } + callback(); }, [callback]);