Last active
August 31, 2020 09:42
-
-
Save jmaicaaan/9325189587c6dcf790f16aa0186e9e1c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
export const App = () => { | |
const { | |
execute: executeNext00AsyncCall, | |
} = executeNext00AsyncCall(); | |
const { | |
execute: executeNext01AsyncCall(), | |
} = useNext01ApiCall(); | |
const { | |
execute: executeNext02AsyncCall(), | |
} = useNext02AsyncCall(); | |
const [isSubmitting, setIsSubmitting] = React.useState(false); // or use formik | |
const handleOnSubmit = async (formValues) => { | |
setIsSubmitting(true); | |
}; | |
useEffect(() => { | |
if (!isSubmitting) { | |
return; | |
} | |
try { | |
const response00 = await executeNext00AsyncCall(formValues); | |
const response01 = await executeNext01AsyncCall(response00); | |
const response02 = await executeNext02AsyncCall(response01); | |
setIsSubmitting(false); | |
// response02 = final result response | |
// redirect if needed using the response or do anything you want | |
} catch () {} | |
}, [isSubmitting]); | |
return ( | |
... | |
) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment