将Formik道具从表格传递到子部分
我正在尝试将巨大的配方构成尽可能多的模块化,并且在处理OnSubmit功能时遇到了一些麻烦。我不确定如何将Formik的(重置)道具传递给儿童组件,任何建议吗?
(我简化了以下代码,因为处理重置是我发现的唯一问题)
代码:
<Formik
initialValues={formInitialValues}
validate={values => formValidators(values)}
onSubmit={(values, { resetForm }) => {
dispatch(postCreate(values))
resetForm()
}}
>
我想做的是类似于我对“ validate”的事情。
I'm trying to modularize as much as I can a Formik huge formulary and I'm having some trouble dealing with the onSubmit function. I'm not sure how to pass Formik's (resetForm) prop to the child component, any suggestions?
(I simplified the following code, since dealing with resetForm is the only problem I found)
Code:
<Formik
initialValues={formInitialValues}
validate={values => formValidators(values)}
onSubmit={(values, { resetForm }) => {
dispatch(postCreate(values))
resetForm()
}}
>
What I want to do is something similar to what I did with "validate".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
组件
&lt; formik&gt;
的子函数具有单个参数props
,其中包括handlereset()
:在下面的示例中,
handlereset ()
被破坏并传给另一个孩子。live demo
Component
<Formik>
's child function has single argumentprops
, which includeshandleReset()
:In the following example,
handleReset()
is destructured and passed into another child.Live Demo