我正在使用 Formik 构建用户输入表单。我正在使用 withFormik 来处理我的表单。我目前正在像这样在我的组件中传递我的 handleSubmit:
export const CreateForm = withFormik({
mapPropsToValues: () => ({
primarySkill: "12"
}),
validationSchema: () => FormSchema,
handleSubmit: (values, { setSubmitting }) => {
setTimeout(() => {
alert(JSON.stringify(values, null, 2)); // For testing
setSubmitting(false);
}, 1000);
}
})(MyForm);
而不是这样做,我想<CreateForm handleSubmit={handleSubmit} />在我的 App.js(根)组件中传递这样的东西。任何人都可以给我一个提示如何做到这一点,好吗?