Skip to content
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

Switch UI doesn't update when set using resetFields #9611

Closed
Fajer39 opened this issue Mar 10, 2018 · 5 comments

Comments

@Fajer39
Copy link

commented Mar 10, 2018

Version

3.2.3

Environment

Latest chrome, OS: High-Siera, latest react

Reproduction link

https://codesandbox.io/s/n3rnmmrm50

Steps to reproduce

Select some option from select input, then turn switch on and click Submit button. In console.log, you'll see the right output. Then, use allowClear button on Select and click Submit. You will receive empty formValues in console, which is right, but the switch will still be on.

What is expected?

Switch should be turned off by using resetFields function from this.props.form

What is actually happening?

Switch UI is remaining the same, not respecting the value set inside getFieldDecorator

@afc163

This comment has been minimized.

@afc163 afc163 closed this Mar 10, 2018
@Fajer39

This comment has been minimized.

Copy link
Author

commented Mar 10, 2018

@afc163 I don't use custom form-input, I'm using antd Switch and getFieldDecorator. How valuePropName is related here? Please clarify more

@afc163

This comment has been minimized.

Copy link
Member

commented Mar 10, 2018

image

image

Switch don't have value prop so you have to tell form what prop control its state.

@Fajer39

This comment has been minimized.

Copy link
Author

commented Mar 10, 2018

@afc163 I see, thank you for a quick help.

@developdeez

This comment has been minimized.

Copy link

commented Oct 28, 2018

Not sure why but that didnt work for me:

getFieldDecorator("emailNotify", {
                        initialValue: settings.emailNotify,
                        valuePropName: "checked"
                      })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.