First of all, thank you for the library! 👍
Is there a way to pass values from the component state to handleSubmit function? Say, I want to manage some part of the form by myself, then "glue" it with formik-managed values.
I was actually wondering about this, specifically in context of using draft js - I'm not sure how to start integrating that with Formik.
@riseremi thanks for the ❤️ . Not really. You could move that input outside of formik, then pass its state as prop to formik, and you'll have it in handleSubmit(values, { props}). However, can you explain in more detail what you are trying to do with your form? I have yet to come across something that could not be done within Formik by creating a custom component.
@mwickett Draftjs stores state internally AFAIK. Thus you would treat it as custom input component and send its value up to Formik with setFieldValue. I will try this myself either tonight or tomorrow and add it to the readme/examples
@jaredpalmer I was overthinking things so it turned out to be very simple. I just need to manage the whole state of the form with Formik.
I managed to get it working with setValues helper — I just pass values from the state like:
handleSomeAction = () => {
// Do something with this action
// ...
// Update Formik values
this.props.setValues({
...this.props.values,
type: this.state.type,
});
};
Thank you for your time!
Case solved.
@mwickett Formik x Draftjs example: https://codesandbox.io/s/QW1rqjBLl
Thanks so much for putting this together. :)
Most helpful comment
@jaredpalmer I was overthinking things so it turned out to be very simple. I just need to manage the whole state of the form with Formik.
I managed to get it working with
setValueshelper — I just pass values from the state like:Thank you for your time!
Case solved.