Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

handleLoad makes the field invalid #1183

Open
anujgakhar opened this issue Sep 12, 2018 · 2 comments
Open

handleLoad makes the field invalid #1183

anujgakhar opened this issue Sep 12, 2018 · 2 comments

Comments

@anujgakhar
Copy link

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.

@davidkpiano
Copy link
Owner

Do you have a fix? I welcome any PRs.

@anujgakhar
Copy link
Author

anujgakhar commented Sep 12, 2018 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants