InitialValue is called defaultValue. It only changes the first time an assignment is made, but it is a little different because the initialValue is changed by other changes. However, when the obtained data is returned to render, the initialValue value does not change, so it is very unpredictable.
Solution: ` ` ` ` this. Props. Form. ResetFields (); ` ` `
For example: If the first step is to modify the operation, some default values will be filled in, if not processed, the second step will perform the new operation, the first default value will be carried, resulting in the new pop-up box when the form form will be a value, the effect is very bad experience.
Found behind with reports in componentWillReceiveProps Modal file to add reset, can refresh the form form
componentWillReceiveProps(nextProps) {
if(! nextProps.modal.modalUpdateDetail) { this.props.form.resetFields(); }Copy the code
Later I would still jump in the same pit, but this time it was not in Modal Form, but in tab-like component switching data, the content of this.state was changed, but the initialValue of render still retained the original data solution. 1 My first thought was to force refresh, Window.location.reload () is not ideal
2 root have to cure, I know that is a question of the initialValue But if the reference of the original in componentWillReceiveProps reset the form data, there will be other problems, Because ` ` ` componentWillReceiveProps ` ` this function you may be triggered because of other reasons
componentWillReceiveProps(nextProps) {
if(! nextProps.modal.modalUpdateDetail) { this.props.form.resetFields(); }Copy the code
Since then thought, because the initialValue has initialized, that at the time of switching operation, remove it ok, so leave the operating function is added in this. Props. Form. ResetFields ();