diff options
author | Sebastian <sebasjm@gmail.com> | 2022-03-30 14:22:42 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-03-30 14:23:28 -0300 |
commit | 8642f8edcd1aa8fe18c50d534f485debf1df01c9 (patch) | |
tree | 03c8d62706e7d3e0b6f38e4ddf8c643582bfad63 /packages/taler-wallet-webextension/src/mui/input/FormControl.tsx | |
parent | bbd6ccf1c7c0baea44234863967e640f5cb10a3a (diff) | |
download | wallet-core-8642f8edcd1aa8fe18c50d534f485debf1df01c9.tar.xz |
fix loop rendering
Diffstat (limited to 'packages/taler-wallet-webextension/src/mui/input/FormControl.tsx')
-rw-r--r-- | packages/taler-wallet-webextension/src/mui/input/FormControl.tsx | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/packages/taler-wallet-webextension/src/mui/input/FormControl.tsx b/packages/taler-wallet-webextension/src/mui/input/FormControl.tsx index 8860ce20d..0f73f8c02 100644 --- a/packages/taler-wallet-webextension/src/mui/input/FormControl.tsx +++ b/packages/taler-wallet-webextension/src/mui/input/FormControl.tsx @@ -1,6 +1,6 @@ import { css } from "@linaria/core"; import { ComponentChildren, createContext, h, VNode } from "preact"; -import { useContext, useState } from "preact/hooks"; +import { useContext, useMemo, useState } from "preact/hooks"; // eslint-disable-next-line import/extensions import { Colors } from "../style"; @@ -152,6 +152,10 @@ function withoutUndefinedProperties(obj: any): any { export function useFormControl(props: Partial<FCCProps> = {}): FCCProps { const ctx = useContext(FormControlContext); const cleanedProps = withoutUndefinedProperties(props); - if (!ctx) return { ...defaultContextValue, ...cleanedProps }; - return { ...ctx, ...cleanedProps }; + + return useMemo(() => { + return !ctx + ? { ...defaultContextValue, ...cleanedProps } + : { ...ctx, ...cleanedProps }; + }, [cleanedProps, ctx]); } |