-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[6.2.0] Initial data passed to sync validate is undefined #2090
Comments
dmeenhuis
added a commit
to dmeenhuis/redux-form
that referenced
this issue
Nov 7, 2016
Yeah, just ran into this as well. Accidentally upgraded from 6.1.1 to 6.2.0 and all my validation functions broke. |
erikras
pushed a commit
that referenced
this issue
Nov 11, 2016
* Values passed to the sync validation function must be defined. Closes #2090 * Fixed linting errors (removed semi-colons)
Published in |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The changes in #1992 introduced a subtle change in the data that is passed to the sync validate function.
I have a form that uses
enableReinitialize
and sync validation. It also receivesinitialValues
when connecting the component.Simplified code example:
When the form is mounted initially, it also calls the validate function. Now, with version 6.1.1, the
values
argument contained the value provided byinitialValues
. In 6.2.0 however, this value is nowundefined
, causing a runtime error in my application.I've pinpointed the cause to this specific line: src/reduxForm.js#L475
In my case the variable
shouldUpdateInitialValues
is set totrue
because I'm usingenableReinitialize
andinitialValues
differs fromstateInitial
(this value is undefined).So in this case,
initial
is updated withstateInitial
, therefore becomingundefined
. This value is then passed to thevalidate
function, causing an error.A fix on my end is trivial, I could just assign a default value in the destructuring, but I'm wondering whether this is the intended behaviour, or that a subtle bug was just introduced?
I suppose from an API-point-of-view it perhaps seems more sensible to always pass at least an empty object as values to the
validate
function, in order to prevent these kind of weird runtime errors. As far as I can tell, this was how it worked in the previous version :)The text was updated successfully, but these errors were encountered: