HandleEdit (record,index) click event, the first click record contains key, the second click does not have key

problem description

clipboard.png

clipboard.png

related codes

/ / Please paste the code text below (do not replace the code with pictures)
/ / Edit

handleEdit =(record,index)=>{
    console.log(this.state.ids,"ids")
    console.log(record,"record")
    console.log(record.key,"key")
    if(this.state.ids.indexOf(record.key)>-1){
        console.log(1)
        let ids = this.state.ids
        this.setState({
            ids:ids.filter(item => item !== record.key),
            isEditVisible:false
        })
        console.log(ids,11)
    }
    this.props.form.resetFields();//
    let userInfo = record;
    this.setState({
        isEditVisible:true,
        userInfo,
        index,
        type:"edit",
    })
}

/ / Button
{

            title:"",
            key:"action",
            render:(text,record,index)=>{
                let flag =0;
                if(this.state.ids.indexOf(index)>-1){
                    flag = 1
                }
                return (
                    <div>
                        <Button onClick={()=>this.handleDelete(record,index)} style={{marginRight:4}}></Button>
                        {/* <Button onClick={()=>this.handleEdit(record,index)} disabled={flag==0?false:true}>{flag==0?"":""}</Button> */}
                        <Button onClick={()=>this.handleEdit(record,index)}>{flag==0?"":""}</Button>
                    </div>
                )
            }
        }


Jul.29,2021

the relevant code given in your problem description is not enough, especially the code that changes to the logical part of the record data is not seen, so you are not sure where the specific problem lies.

according to the existing code, it is recommended that you focus on checking the part of the source code that will affect record.key to see if the record has been changed since the first handleEdit.

Menu