Formik: [Question] How to pass handleSubmit as a prop?

Created on 17 Aug 2017  Â·  1Comment  Â·  Source: formium/formik

I want to pass up values from the form to a parent component. I've looked over the docs but it's not really apparent how I would go about doing that.

For example I want to do something like this:

const MyForm = Formik({
  mapPropsToValues: () => ({}),
  handleSubmit: (values, bag) => props.handleSubmit(values) // ????
})

Thanks!

Most helpful comment

Obviously I wasn't looking hard enough.

Props exist on the bag…

const MyForm = Formik({
  mapPropsToValues: () => ({}),
  handleSubmit: (values, bag) => bag.props.handleSubmit(values)
})

>All comments

Obviously I wasn't looking hard enough.

Props exist on the bag…

const MyForm = Formik({
  mapPropsToValues: () => ({}),
  handleSubmit: (values, bag) => bag.props.handleSubmit(values)
})
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jucesr picture Jucesr  Â·  3Comments

Jungwoo-An picture Jungwoo-An  Â·  3Comments

green-pickle picture green-pickle  Â·  3Comments

ancashoria picture ancashoria  Â·  3Comments

dfee picture dfee  Â·  3Comments