简体   繁体   中英

When building forms with Formik, NOT using withFormik HOC, how do I access history prop?

total noob here. I'm using Formik to build wizard form for user registration in React. The problem is I can't find history prop to redirect user to login page on form submit. The reason I'm using Formik and not withFormik is this seems to be the only way to make multi-step validation work, correct me if I'm wrong

<Formik
        initialValues={initialValues}
        onSubmit={handleSubmit}
        validationSchema={allSchemas[step]}
        render={props => (
          <Form>
            <Wizard {...props}/>
          </Form>
        )}
      />

The history prop comes from the module above.

export default (props) => {
  console.log("props: ", props)
  return (
    <Formik
        initialValues={initialValues}
        onSubmit={handleSubmit}
        validationSchema={allSchemas[step]}
        render={formikBag => (
          <Form>
            <Wizard {...formikBag}/>
          </Form>
        )}
      />
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM