[英]How to clear form after successfully submitting Formik form using redux
I am currently working on a React project which uses Redux and Redux-saga.我目前正在开发一个使用 Redux 和 Redux-saga 的 React 项目。 I am wondering how to make the form reset after successfully completing the async api call.
我想知道如何在成功完成异步 api 调用后重置表单。 using redux and redux saga am I using the
使用 redux 和 redux saga 我在使用
resetform({})
but it immediately resets the form before api is successfully executed但它会在 api 成功执行之前立即重置表单
What I will do :我将要做的 :
isSubmitted
which is a boolean.isSubmitted
,这是一个布尔值。true
just call the resetForm();true
只需调用 resetForm(); According to the doc of Formik :根据Formik的文档:
The latter is useful for calling resetForm within componentDidUpdate or useEffect.
Hope it helps.希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.