react-redux-form
react-redux-form copied to clipboard
handleLoad makes the field invalid
The Problem
Control components' handleLoad() making the field invalid as there is no defaultValue (undefined). This happens when I have fired an onChange(value) already from my custom components' componentdidMount. But since Control's componentDidMount runs after the custom component, it dispatches a setErrors()as there is no defaultValue
Steps to Reproduce
I have a custom dropdown which turns into a label if there is only one option to show. So in the componentDidMount of my custom component, I have this code
if (options && options.length === 1) { this.props.onChange(options[0].value); }
This seems to work OK, but the field stays invalid in the store, as this is a required field.
Expected Behavior
After dispatching onChange, the field should become valid.
Actual Behavior
The field stays invalid in the store.
Do you have a fix? I welcome any PRs.
I don’t have a fix yet - just want to know what would the fix be ? Should the handleLoad pick up value as well, in addition to defaultValue ?
On 12 Sep 2018, at 17:36, David Khourshid [email protected] wrote:
Do you have a fix? I welcome any PRs.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.