react-hook-form doesn't recover from isSubmitting state
Asked Answered
D

0

6

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

Downcome answered 13/3, 2023 at 18:28 Comment(1)
github.com/react-hook-form/react-hook-form/discussions/9879 "RHF doesn't support throwing errors in the submit handler with the current API design."Commodity

© 2022 - 2024 — McMap. All rights reserved.