diff options
author | Sebastian <sebasjm@gmail.com> | 2024-01-15 17:34:19 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-01-15 17:36:48 -0300 |
commit | 2e2cf4049a771c82fcc520686de3ace7603baa05 (patch) | |
tree | 620ab22d4fc0f621d0a574c8f98d1c49f1d67804 /packages/taler-wallet-webextension/src/utils/index.ts | |
parent | ef0bb60f23c0c755814f648b8d71a29a843e066c (diff) | |
download | wallet-core-2e2cf4049a771c82fcc520686de3ace7603baa05.tar.xz |
fixes #8083
Diffstat (limited to 'packages/taler-wallet-webextension/src/utils/index.ts')
-rw-r--r-- | packages/taler-wallet-webextension/src/utils/index.ts | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/packages/taler-wallet-webextension/src/utils/index.ts b/packages/taler-wallet-webextension/src/utils/index.ts index ad4eabf15..d83e6f472 100644 --- a/packages/taler-wallet-webextension/src/utils/index.ts +++ b/packages/taler-wallet-webextension/src/utils/index.ts @@ -15,6 +15,7 @@ */ import { createElement, VNode } from "preact"; +import { useCallback, useMemo } from "preact/hooks"; function getJsonIfOk(r: Response): Promise<any> { if (r.ok) { @@ -26,8 +27,7 @@ function getJsonIfOk(r: Response): Promise<any> { } throw new Error( - `Try another server: (${r.status}) ${ - r.statusText || "internal server error" + `Try another server: (${r.status}) ${r.statusText || "internal server error" }`, ); } @@ -89,6 +89,7 @@ export function compose<SType extends { status: string }, PType>( ): (p: PType) => VNode { function withHook(stateHook: () => RecursiveState<SType>): () => VNode { function TheComponent(): VNode { + //if the function is the same, do not compute const state = stateHook(); if (typeof state === "function") { @@ -102,7 +103,9 @@ export function compose<SType extends { status: string }, PType>( } // TheComponent.name = `${name}`; - return TheComponent; + return useMemo(() => { + return TheComponent + }, [stateHook]); } return (p: PType) => { |