From fede0a865d88bc304c2724eb0f19f3a188bae9c3 Mon Sep 17 00:00:00 2001 From: Romain Lenzotti Date: Tue, 30 Mar 2021 09:14:38 +0200 Subject: [PATCH] fix(react-formio): Fix useForm create instance method --- packages/react-formio/src/components/form/useForm.hook.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/react-formio/src/components/form/useForm.hook.ts b/packages/react-formio/src/components/form/useForm.hook.ts index c7bd1c50..70644a7e 100644 --- a/packages/react-formio/src/components/form/useForm.hook.ts +++ b/packages/react-formio/src/components/form/useForm.hook.ts @@ -23,7 +23,10 @@ export const useForm = ({ useEffect( () => () => { isLoaded.current = false; - return formio.current ? formio.current.destroy(true) : null; + if (formio.current) { + formio.current.destroy(true); + } + formio.current = null; }, [formio] ); @@ -67,6 +70,8 @@ export const useForm = ({ const createWebFormInstance = async (srcOrForm: any): Promise => { const { formioform, onFormReady } = props; if (instance.current) { + formio.current = await instance.current.ready; + return formio.current; }