diff options
Diffstat (limited to 'packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts b/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts index 04a6dbb18..d13a68383 100644 --- a/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts +++ b/packages/taler-wallet-webextension/src/hooks/useAsyncAsHook.ts @@ -13,9 +13,7 @@ You should have received a copy of the GNU General Public License along with TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import { - NotificationType, TalerErrorDetail -} from "@gnu-taler/taler-util"; +import { NotificationType, TalerErrorDetail } from "@gnu-taler/taler-util"; import { TalerError } from "@gnu-taler/taler-wallet-core"; import { useEffect, useMemo, useState } from "preact/hooks"; import * as wxApi from "../wxApi.js"; @@ -44,19 +42,23 @@ interface WithRetry { } export type HookResponse<T> = HookOk<T> | HookError | undefined; -export type HookResponseWithRetry<T> = ((HookOk<T> | HookError) & WithRetry) | undefined; +export type HookResponseWithRetry<T> = + | ((HookOk<T> | HookError) & WithRetry) + | undefined; export function useAsyncAsHook<T>( fn: () => Promise<T | false>, deps?: any[], ): HookResponseWithRetry<T> { - const [result, setHookResponse] = useState<HookResponse<T>>(undefined); - const args = useMemo(() => ({ - fn - // eslint-disable-next-line react-hooks/exhaustive-deps - }), deps || []) + const args = useMemo( + () => ({ + fn, + // eslint-disable-next-line react-hooks/exhaustive-deps + }), + deps || [], + ); async function doAsync(): Promise<void> { try { |