From 22914b3921211295f9b2cc0f7f8d57414a56e7ba Mon Sep 17 00:00:00 2001 From: Seligmann Date: Sat, 7 Oct 2023 15:37:42 -0500 Subject: [PATCH] Added pre-onSubmit callback to attach 'called' state --- src/components/forms/EventForm.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/forms/EventForm.tsx b/src/components/forms/EventForm.tsx index 3e20218..1a3756b 100644 --- a/src/components/forms/EventForm.tsx +++ b/src/components/forms/EventForm.tsx @@ -83,6 +83,17 @@ function FormWarning(props: { className?: string; title?: string; children: stri ); } +const checkIfSubmitted = (callback: any) => { + const [called, setCalled] = useState(false); + + return (e: any) => { + if (!called) { + setCalled(true); + callback(e); + } + } +} + const EventForm: FunctionComponent = ({ context, onSubmit, @@ -175,7 +186,7 @@ const EventForm: FunctionComponent = ({ }, [watchedEventTiming]); return ( -
+