Skip to content

Instantly share code, notes, and snippets.

@jmaicaaan
Last active August 31, 2020 09:42
Show Gist options
  • Save jmaicaaan/9325189587c6dcf790f16aa0186e9e1c to your computer and use it in GitHub Desktop.
Save jmaicaaan/9325189587c6dcf790f16aa0186e9e1c to your computer and use it in GitHub Desktop.
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