-
-
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
[v8.0.4] Initial Values not available in Field componentWillMount #4304
Comments
I believe this is also the cause of my issue: I am testing the upgrade to redux-form 8.0.4 using jest and enzyme's I am getting PropTypes warnings that required values are the wrong type (required boolean fields being passed empty strings). Logging renders I see a first render with empty string values, followed by a second render with the correct values. The first render seems to be generating the warning. |
Also get this error. |
the same error with sync validation and array... I don't get initial value of array to validate function in first render |
Hi @erikras, any thoughts about this? May be any temp workaround? For my use cases redux-form v8 is completely broken because of this issue. |
componentWillMount is deprecated |
@jjosef You are correct. However, to clarify, moving this call to a constructor (as per the deprecation notification) shows the same problem. If there's something else you think I should be doing, please let me know! |
I'm running into this same issue - I'm seeing the initialize action dispatched to Redux, the store is showing the correct values for both the Has anyone had any luck getting around this? |
Also hitting this same issue with empty strings for |
import React from 'react';
/**
* redux-form introduced a breaking bug in 8.0 where forms are no longer initialized before the initial render. Some of our forms rely on this behavior. To avoid issues caused by this bug, we can decorate those forms with this decorator to hold rendering until the redux-form is initialized.
*/
export default Component => (
props => {
if (!props.initialized && props.initialValues !== undefined) {
return null;
}
return (
<Component {...props} />
);
}
); |
I suppose this can lead to blinks or UI shifts |
I've just encountered this as well. I think the problem is that react-redux has slightly changed behaviour after switching to the new context API. The initialize action is fired and the store is updated before rendering the connected field, but react-redux serves up a snapshot from when the render began. While this is annoying in this case, it does seem like a more correct behaviour. I think it can be very simply fixed by reading |
then modal doesn't render an empty string |
Issue is gone after updating to [email protected] |
Upgrading to [email protected] and [email protected] appears to have introduced this problem into my application. |
Any news on that facing the same issues... |
@eugensunic Please read the deprecation notice and consider using final form... |
@levino I already have , currently on 7.4.2 and the next step in migration only. |
This might be resolved with 8.3.10. From a first look, I didn't encounter the problem anymore. |
Are you submitting a bug report or a feature request?
Bug Report
What is the current behavior?
In
componentWillMount
forField
/FieldArray
etc. components, field values are not set to their initialValues. See that in theconsole.log
fromcomponentWillMount
in the sandbox the field value is""
.What is the expected behavior?
In 7.4.2, initial values were available in
Field
components during thecomponentWillMount
lifecycle. See that theconsole.log
now readsjim
as per the provided initial value.Sandbox Link
Redux Form 8.0.4: https://codesandbox.io/s/0yvykqqxwl
Redux Form 7.4.2: https://codesandbox.io/s/p423x6y30
What's your environment?
Redux Form 8.0.4
Other information
Please let me know if you need any more clarity and thanks for all the work you do!
The text was updated successfully, but these errors were encountered: