-
-
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
Values via props.change() in componentDidMount() will be overwritten #3706
Comments
I noticed the same issue. Basically, the componentDidMount is not working to change/dispatch(change) values in the form. I had the same logic working on 7.0.3 and it is not working on 7.2.0. |
btw. sorry I haven't had the time to create a sandbox for this problem. |
I also encountered the same problem. It is working on 7.1.2 and it is not working on 7.2.0. |
I managed to condense our app to a much simpler version with only to fields the bug still is there. https://codesandbox.io/s/konx6r9zpv The second field keeps its inital value, the first fields value is overwritten by the second Happy to help with fixing this 👍 |
If it does not introduce any side effects in your app you can set Prior to 7.2.0 |
Duplicate of #3690 |
Published fix 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. |
I assume this is a bug, since it worked in previous versions of redux-form.
Edit: Can confirm it worked in 7.1.2
We have a form with a few fields which may have a default value. Those are set via props.change(),
see the shortened code below.
What is the current behavior?
@@redux-form/INITIALIZE
is dispatched as first action, followed a couple of@@redux-form/REGISTER_FIELD
@@redux-form/CHANGE
is dispatched with correct values.country_code
is a registered field the action results in the correct change of thevalues
state forcountry_code
.Then again
@@redux-form/INITIALIZE
is dispatched resulting in overwriting the previously set values. Then fields are registered and unregistered again.To this time there is not a single action which is not dispatched by redux-form.
Some information to set the initial value of those fields are only available as props, I am unsure about how to use
reduxForm({ ...initialValues: { ... }})
to do this. This would work, since we use this method to set a initial value to a field.Form Validation will somehow consider those set values, they are even displayed correctly. But are missing when submitting.
Note: There is not much more logic in this app besides sending the form to server and displaying a result page.
What is the expected behavior?
I don't expect the form the initialize twice, resulting in overwriting previously set data.
Sandbox Link
I will setup a demo for this as soon as I have time for it.
Edit: I condensed the application we have: https://codesandbox.io/s/konx6r9zpv
What's your environment?
redux-form: 7.2.0
the app is tested with: Chrome, Firefox, Safari, IE10/11 (😢) on osx/window
The text was updated successfully, but these errors were encountered: