DEV Community

Discussion on: React & Formik Build forms more efficiently

Collapse
 
srikanth597 profile image
srikanth597

Btw , how does formik remembers change events w.r.t to form object? Does it based on html element id or name ?

Collapse
 
przpiw profile image
Damian Piwowarczyk

useFormik it is a custom hook that returns state and helper methods.
We reuse the same exact change handler function handleChange for each HTML input
We pass an id and name HTML attribute that matches the property we defined in initialValues
We access the field’s value using the same name (email -> formik.values.email)
I hope that answered your question :)