diff options
Diffstat (limited to 'packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx')
-rw-r--r-- | packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx b/packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx index 4019fbc89..4397fc197 100644 --- a/packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx +++ b/packages/exchange-backoffice-ui/src/handlers/FormProvider.tsx @@ -1,6 +1,6 @@ import { AbsoluteTime, TranslatedString } from "@gnu-taler/taler-util"; import { ComponentChildren, VNode, createContext, h } from "preact"; -import { MutableRef, StateUpdater, useRef } from "preact/hooks"; +import { MutableRef, StateUpdater, useEffect, useRef } from "preact/hooks"; export interface FormType<T> { value: MutableRef<Partial<T>>; @@ -49,6 +49,11 @@ export function FormProvider<T>({ children: ComponentChildren; }): VNode { const value = useRef(initialValue ?? {}); + useEffect(() => { + return function onUnload() { + value.current = {}; + }; + }); return ( <FormContext.Provider value={{ initialValue, value, onUpdate, computeFormState }} |