Open tkrebs2 opened 4 years ago
They're undefined because in the code above anonymous dictionary is being passed to Formik's parameter named initialValues
, no variable is being created. And they're not in props as well.
If I understood the problem correctly, simply declare & init a variable named initialValues
above JSX code, pass it to Formik's initialValues
param, then compare it memberwise with values
in onSubmit.
I have a form that uses
enableReinitialize
to hydrate myinitialValues
from an api call. I have a use case where I want/need to compareinitialValues
andvalues
inonSubmit
to determine what values to send in a request. I don't want to send values that don't differ from what's ininitialValues
.Haven't had much feedback asking this question in various other places. I have a codesanbox here