From b5d3c1a8ccce8cb4967173e86a0efdb1a48cd846 Mon Sep 17 00:00:00 2001 From: prem22k Date: Tue, 20 Jan 2026 23:16:54 +0530 Subject: [PATCH] fix: prevent double loading spinners in Form component --- src/components/Form.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/Form.tsx b/src/components/Form.tsx index 2520b3f51..2d723aa90 100644 --- a/src/components/Form.tsx +++ b/src/components/Form.tsx @@ -282,7 +282,7 @@ export const Form = (props: FormProps) => { isMounted.current = true; return () => { isMounted.current = false; - } + }; }, []); useEffect(() => { @@ -294,6 +294,7 @@ export const Form = (props: FormProps) => { return; } + let ignore = false; const createInstance = async () => { if (renderElement.current === null) { console.warn('Form element not found'); @@ -315,11 +316,12 @@ export const Form = (props: FormProps) => { options, ); + if (ignore) { + instance.destroy(true); + return; + } + if (instance) { - if (!isMounted.current) { - instance.destroy(true); - return; - } if (typeof formSource === 'string') { instance.src = formSource; } else if (typeof formSource === 'object') { @@ -345,6 +347,10 @@ export const Form = (props: FormProps) => { }; createInstance(); + + return () => { + ignore = true; + }; }, [formConstructor, formReadyCallback, formSource, options, url]); useEffect(() => {