question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pass values from component state to handleSubmit

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

32reactions
riseremicommented, Jul 31, 2017

@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.

3reactions
jaredpalmercommented, Jul 31, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

I want to pass my input values from Form to handleSubmit ()
Your messageForm should update your state using an onChange handler. Then handleSubmit should preventDefault() and dispatch your sendNewMessage ...
Read more >
React interactivity: Events and state - Learn web development
We want our handleSubmit() function to ultimately help us create a new task, so we need a way to pass information from <Form...
Read more >
withFormik() | Formik
Create a higher-order React component class that passes props and form handlers (the " FormikBag ") into your component derived from supplied options....
Read more >
Handling Events - React
React events are named using camelCase, rather than lowercase. With JSX you pass a function as the event handler, rather than a string....
Read more >
What's the difference between `handleSubmit` and `onSubmit`?
How do I pass form value(s) to my own submit handler? # ... Simply write your components as you normally would, passing handleSubmit...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found