The problem of react antd table modification

Click modify in the table, and there is a form in a modal, in the pop-up window. Now there is a problem when you click to modify the value.

parent table

// state
    handleEdit = (record: IRoleData) => {
        console.log(record)
        this.setState({
            visible: true,
            roleData: record
        })
    }
    
    // roleData poprs
        <ModalForm visible={visible} roleData={roleData} onCancel={this.handleCancel} onOk={this.handleOk}/>
    

the subcomponent sets the value of form when props is updated

    componentWillUpdate(){
        this.initForm()
    }

    /* form*/
    initForm() {
        if (this.props.roleData) {
            console.log(this.props.roleData)
            this.props.form.setFieldsValue({...this.props.roleData})
        }
    }

the problem now is that if I do this, I will report a stack overflow.

my idea is that when you first initialize a subcomponent, because roleData has no value, if you click edit, then roleData will have a value, and then the setting method of form will be called in the life cycle of the change of the props of the subcomponent. It should work. But something went wrong. Please tell me what the reason is.

complement

export default Form.create({
    mapPropsToFields: (props: IModalFormProps) => {
        if (!props.roleData) {
            return
        }
        return {
            name: Form.createFormField(props.roleData.name),
            state: Form.createFormField(props.roleData.state),
        }
    },
    onValuesChange: (props, changeValue, allValue) => {
        console.log(changeValue)
    }
})(ModalFormClass)
it still doesn"t work after using the mapPropsToFieldsz method. Click modify, and you still can"t see the value of the parent component. Display
in form.

all right

 name: Form.createFormField({value: props.roleData.name}),
 state: Form.createFormField({value: props.roleData.state}),
found that the corresponding fields should correspond to value one by one, with embarrassment in uppercase
.
Mar.23,2021

official statement
clipboard.png


generally, spillovers are in a dead end.

componentWillUpdate () is more likely to occur when props or state is updated, and your initForm () will update props, and launch componentWillUpdate (), again, so it must have overflowed all the time.

add a criterion to compare the props/state to be updated with the current props/state. The initForm () is not equal until it is not equal.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4f4cb-45032.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4f4cb-45032.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?