react-hook-form 无法从 isSubmitting 状态恢复

kar*_*una 6 reactjs react-hooks react-hook-form

我在提交处理程序(异步函数)中进行 API 调用。如果出现错误,我会显示警报,然后从 catch 块中重新抛出,以便 Sentry 等监控工具可以报告该错误。

要禁用该过程中的提交按钮,我使用formState.isSubmitting钩子返回useForm。我预计isSubmitting在解决或拒绝 Promise 的情况下会变成 false,但即使被拒绝它仍然是 true。

这是代码:https://codesandbox.io/s/axios-interceptor-react18-forked-89i3nq ?file=/src/App.js