You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some libraries like downshift.js don't give you a native event in the change handler. I'm not a fan of this design decision but it is what it is. So if I manually call onChange on a formik Field with an event, it blows up on this line when it tries to destructure event.target.:
This is a 4th or 5th issue around handleChange / event handling / currying since v2. Going to make an umbrella so we can centralize and then debate next steps to minimize api churn
In v2 this was changed to only accept either a string or a react event, and assumes that any input that isn't a string is a react event, which will break the forms of anyone who happened to be using it assuming it could take any value. This doesn't seem to currently be mentioned as a breaking change in the migration docs.
馃悰 Bug report
Current Behavior
Some libraries like downshift.js don't give you a native event in the change handler. I'm not a fan of this design decision but it is what it is. So if I manually call
onChange
on a formikField
with an event, it blows up on this line when it tries to destructure event.target.:formik/packages/formik/src/Formik.tsx
Line 592 in c959f47
This is the error:
Cannot read property 'type' of undefined
So, what I'm doing currently is just passing in an empty target object, and it seems to solve the problem.
Expected behavior
If the code above didn't explode, and instead gracefully handled a null object in event.target.
Reproducible example
https://codesandbox.io/s/formik-codesandbox-template-xnfxx
Suggested solution(s)
Gracefully initialize an empty object if it doesn't exist.
Your environment
The text was updated successfully, but these errors were encountered: