diff --git a/example/src/features/SubmitHandling.tsx b/example/src/features/SubmitHandling.tsx index b29dd62..4095966 100644 --- a/example/src/features/SubmitHandling.tsx +++ b/example/src/features/SubmitHandling.tsx @@ -46,6 +46,7 @@ const SubmitHandling = (e: any) => { useEffect(() => { setFormInstance(form); + console.log('formInstance', formInstance, form) }, [form]); useEffect(() => { @@ -75,6 +76,7 @@ const SubmitHandling = (e: any) => { const customHandling = (event: any) => { event.preventDefault(); + console.log('HERE', formInstance) if (!isFormSubmitting && formInstance) { setFormSubmitting(true); formInstance.submit( diff --git a/package.json b/package.json index 01d1e0e..450159c 100644 --- a/package.json +++ b/package.json @@ -78,5 +78,6 @@ "postcss": "8.4.21", "webpack": "5.76.0" }, - "dependencies": {} + "dependencies": {}, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" } diff --git a/src/Form.tsx b/src/Form.tsx index c43b582..dca4225 100644 --- a/src/Form.tsx +++ b/src/Form.tsx @@ -53,8 +53,8 @@ function CollectForm(props: ICollectFormProps) { const isProviderExists = typeof dispatchFormStateUpdate === 'function' && - typeof dispatchResponseUpdate === 'function'; - + typeof dispatchResponseUpdate === 'function'; // typeof dispatchFormInstanceContextUpdate === 'function'; + useEffect(() => { if ( isBrowser && @@ -69,11 +69,13 @@ function CollectForm(props: ICollectFormProps) { onUpdateCallback(state); } isProviderExists && dispatchFormStateUpdate(state); + // isProviderExists && dispatchFormInstanceContextUpdate({qwe:1}); + // console.log('tyoe of dispatchFormСontext', typeof dispatchFormСontext, '-->', typeof dispatchFormStateUpdate, '--->dispatchFormInstanceContextUpdate', typeof dispatchFormInstanceContextUpdate) } ); dispatchFormСontext({ type: 'FORM_MOUNTED' }); - + if (cname) { form.useCname(cname); } @@ -83,7 +85,13 @@ function CollectForm(props: ICollectFormProps) { } setFormInstance(form); - dispatchFormInstanceContextUpdate(getFormInstance()); + + // console.log('qweqweqw',dispatchFormСontext, dispatchFormInstanceContextUpdate) + // if (typeof dispatchFormInstanceContextUpdate === 'function') { + dispatchFormInstanceContextUpdate(getFormInstance()); + // } else { + // console.log('ELSE', dispatchFormInstanceContextUpdate, dispatchResponseUpdate, dispatchFormStateUpdate, getFormInstance()) + // } } return () => { @@ -102,6 +110,7 @@ function CollectForm(props: ICollectFormProps) { const submitHandler = (e: React.SyntheticEvent) => { e.preventDefault(); + console.log('Default submitHandler SDK', submitHandler) const form: IVGSCollectForm = getFormInstance(); if (!form) { @@ -145,6 +154,7 @@ function CollectForm(props: ICollectFormProps) { return (
diff --git a/src/provider.tsx b/src/provider.tsx index 47312ae..958fb00 100644 --- a/src/provider.tsx +++ b/src/provider.tsx @@ -12,10 +12,9 @@ export const GlobalSubmitContext = createContext