Formik: what is the difference between using formik or just reactjs itself?

Created on 27 Feb 2018  路  5Comments  路  Source: formium/formik

Question

Current Behavior

seems just as if I am writing the whole form.... nothing much less

Desired Behavior

Suggested Solutions

Not really sure, what exactly is the difference by using formik makes?
What is the advantage for using this? Please be concrete with some example scenarios, if possible!
Thank you for writing a open source goodie!

Additional Information


  • Formik Version: latest
  • React Version: latest
  • TypeScript Version: n/a
  • CodeSandbox Link: n/a
  • OS:
  • Node Version:
  • Package Manager and Version:
stale

Most helpful comment

I actually DO appreciate it now! VERY VERY VERY NICE way to abstract form evaluations from the form and extremely flexible. LOVING IT!!!
setFieldValue nailed lots edge cases.
Thank you @jaredpalmer and contributors!

All 5 comments

@adamchenwei hi, can you write simple example like this - https://codesandbox.io/s/q8yRqQMp, on the pure react? and we will compare :)

You're writing the parts of your form that are very particular of your needs for that specific form. But you're avoiding writing all the parts that you'd need to write for most forms.

For instance, you declare what are the rules to validate a given field or the overall form data that the user is providing, but you're freed from all the troubles of invoking these validations at the right time, and set up the state that flags to your render that an field is currently with validation errors, etc.

You get for free the state about which fields have been touched and are different from the initial state in which the form was loaded.

That's just two things that come to mind, and I'm sure more seasoned users of this lib can provide even more. Hope it helps.

As @pgrekovich mentioned above, if you really try to re-create some of the examples this repo provide, with pure react without using this or other similar library, you'll be able to better appreciate what Formik does for you. The parts it does not do for you (presumably taking care of actually rendering the form fields, errors and everything), is because if it did so, it'd be less versatile for a variety of situations and needs.

The README says it nicely:

Formik is a small library that helps you with the 3 most annoying parts:

  • Getting values in and out of form state
  • Validation and error messages
  • Handling form submission

Once you write even a simple example like a contact form in plain React and then in Formik, you will appreciate this library.

Hola! So here's the deal, between open source and my day job and life and what not, I have a lot to manage, so I use a GitHub bot to automate a few things here and there. This particular GitHub bot is going to mark this as stale because it has not had recent activity for a while. It will be closed if no further activity occurs in a few days. Do not take this personally--seriously--this is a completely automated action. If this is a mistake, just make a comment, DM me, send a carrier pidgeon, or a smoke signal.

I actually DO appreciate it now! VERY VERY VERY NICE way to abstract form evaluations from the form and extremely flexible. LOVING IT!!!
setFieldValue nailed lots edge cases.
Thank you @jaredpalmer and contributors!

Was this page helpful?
0 / 5 - 0 ratings