[英]react-final-form remove initial values on form.reset
I have a react-final-form which can pre-populate using initialValues
like so:我有一个 react-final-form 可以使用initialValues
预先填充,如下所示:
<Form
onSubmit={onSubmit}
initialValues={filterParams}
render={({ handleSubmit, values, form }) => (
<form id="productsFilterForm" onSubmit={handleSubmit}>
...
This works great, prefilling the form as I want.这很好用,可以根据需要预先填写表格。 But I also have a reset button that triggers form.reset()
.但我也有一个触发form.reset()
的重置按钮。 When a user clicks this, I want it to completely reset the form, ignoring the initialValues
but everything I have tried always maintains these.当用户单击它时,我希望它完全重置表单,忽略initialValues
但我尝试过的所有内容始终保持这些。 Any ideas?有任何想法吗?
You can pass new initialValues
to form.reset()
.您可以将新的initialValues
传递给form.reset()
。 You want form.reset({})
.你想要form.reset({})
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.