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

initialValue not changed on props changed #10612

Closed
zzsoszz opened this issue May 22, 2018 · 4 comments
Closed

initialValue not changed on props changed #10612

zzsoszz opened this issue May 22, 2018 · 4 comments

Comments

@zzsoszz
Copy link

zzsoszz commented May 22, 2018

#- [ ] I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.5.3

Environment

浏览器版本

Reproduction link

http://www.baidu.com

Steps to reproduce

              
                    <div id="div1">
                        pkid:{this.props.pkid}
                    </div>
                    <FormItem
                        {...formItemLayout}
                        label="产品ID"
                        hasFeedback
                    >
                        {getFieldDecorator('pkid', {
                            initialValue:this.props.pkid,
                            rules: [
                                { required: true, message: '产品ID!' },
                            ],
                        })(
                            <Input placeholder="a-10" />
                        )}
                    </FormItem>

What is expected?

initialValue will changed on this.props.pkid changed

What is actually happening?

initialValue is fist seted value

qq 20180522100953
qq 20180522101001

@afc163
Copy link
Member

afc163 commented May 22, 2018

That is why it is called initial value.

#5109

@afc163 afc163 closed this as completed May 22, 2018
@zzsoszz
Copy link
Author

zzsoszz commented May 22, 2018

handleSubmit= (values) => {
if(this.props.onOk)
{
this.props.onOk(values);
this.props.form.resetFields();
}
}

called this.props.form.resetFields() after form submit resolved my problem

@braian125
Copy link

#22372 (comment)

@reza-asadollahi
Copy link

it because initialValue will set in Form componentDidMount lifecycle,
when you update initialValue it won't set inputs value again
you can use these methods:

/** for reset all input values: */
this.props.form.resetFields();
/** for update inputs values: */
this.props.form.setFieldsValue(newFormFieldsValues);

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

No branches or pull requests

4 participants