I make an API call in my submit handler (async function). In case of error, I show an alert and then re-throw from the catch block, so that monitoring tools like Sentry can report it.
To disable the submit button in the process, I use formState.isSubmitting
returned by the useForm
hook. I'd expect isSubmitting
to turn false in case of both resolution or rejection of the Promise, but it stays true even upon rejection.
Here's the code: https://codesandbox.io/s/axios-interceptor-react18-forked-89i3nq?file=/src/App.js