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?
Just use vanilla React if you need more control
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?
Are you suggesting something like: <Formik values={} touched={} errors={} /> ?
Yes.
I may have over complicated the initial request/proposal a bit by mentioning exposing validation tools and submitting outside of Formik. The simplest form of the proposal would just be to introduce values, touched, errors and some onChange handler.
This will allow, at the very least, referencing the forms state outside of Formik - and changing the state from non-form related actions
This will allow, at the very least, referencing the forms state outside of Formik - and changing the state from non-form related actions
@julienvincent @jaredpalmer I'm evaluating this lib now. Is this not currently possible/feasible?
Only when the submit handler is fired (unless there is another way I missed?).
Most helpful comment
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?