javascript 未定义“handleSubmit”

63lcw9qa  于 2023-05-12  发布在  Java
关注(0)|答案(1)|浏览(138)

111号线:22:未定义“handleSubmit”。在哪里以及如何调用handleSubmit

const MyForm = ( handleSubmit, setvalues, values, handleBlur, handleChange, touched, errors ) => {

  const formik = useFormik({
  initialValues: {
    NameoftheUPSIProject: '',
    InformationSharedBy: '',
    InfoSharedwithrespectto: '',
    InsiderTypes: '',
    ContactPerson: '',
    NameoftheOrganization: '',
    DateofSharing: '',
    ParticularofInformationShared: '',
    PurposeofSharing: '',
    ModeofSharing: '',
  },
  validationSchema: formValidation,
  onSubmit: (values) => {
    apple(values);
  },
});

}
我已经删除了以前的错误,但我现在面临这个错误:https://docs.google.com/document/d/1uwfZR36JMvscNMvdSyB9g6AZE3Gj_sdnuU2-c-XcwTM/edit?usp=sharing

gudnpqoy

gudnpqoy1#

你应该使用props来接收你的组件的所有props,如下所示:

const MyForm = (props) => {...}

然后使用props.handleSubmit访问每个prop,依此类推。或者你可以像这样使用解构:

const MyForm = ({ handleSubmit, setvalues, values, handleBlur, handleChange, touched, errors }) => {...}

您的代码中缺少了花括号,这可能是您无法读取任何props的原因

相关问题