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.

Formik as a controlled component

See original GitHub issue

It would be nice to be able to use Formik as a controlled component, perhaps as an ‘advanced’ API. This will allow more control over the forms state and allow triggers for submitting the form outside of Formik’s render.

For this to be possible it would probably be necessary to also expose any validation tools used internally when handleSubmit is called.

Thoughts?

Issue Analytics

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

github_iconTop GitHub Comments

20reactions
jaredpalmercommented, Sep 27, 2017

Just use vanilla React if you need more control

4reactions
julienvincentcommented, Sep 27, 2017

Perhaps this could have a little more discussion around it, even if just to give future people reading an understanding of why or why not the decision was made.

IMO this would add significant value to the library with minimal code changes required - which I say with little knowledge of the architecture of the library so the latter may not be true.

What are your objections to using <Formik /> as a controlled component?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Field
as can either be a React component or the name of an HTML element to render. Formik will automagically inject onChange , onBlur...
Read more >
Controlled vs Uncontrolled Components in React - Pieces.app
Formik is a complete solution that helps you to implement form validation, keep track of visited fields, and handle form submission in an ......
Read more >
formik warning, A component is changing an uncontrolled ...
Warning: A component is changing an uncontrolled input of type text to be controlled. Input elements should not switch from uncontrolled to ...
Read more >
A guide to React forms and events using Formik
The Field component in Formik is used to automatically set up React forms with Formik. It's able to get the value by using...
Read more >
How to Use Formik to Create Forms in React
You can create React forms using either controlled components or uncontrolled components. A controlled component is one whose form data is ...
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