The Table form of antd will be checked last time by default. How to clear it?

I set the default check box 13, the first submission is correct, the second time, the page also checked the last submission, not configured by getCheckboxProps rendering, and then onChange this, the output is the last submission (132) + this default (13) + new check (45) = [1, 3, 2, 1, 3, 4, 5]
I am puzzled.



class User extends Interval {
    constructor(props) {
        super(props);
        this.state = {
            synCode: [],
        }
    }

    render() {
        console.log(this.state.synCode);
        const _this = this;
        const rowSelection = {
            getCheckboxProps(record) {
                return {
                    defaultChecked: record.leader === 1, // 
                };
            },
            onChange(selectedRowKeys) {
                console.log("",selectedRowKeys);
                // console.log("",_this.state.synCode);
                _this.setState({synCode: selectedRowKeys})

            },
        };
       
        return (
            <Table rowSelection={rowSelection} columns={columns} dataSource={this.state.data} />
        );
    }
}

when you want to clear the check box, set this.state.selectedRowKeys= [];

const rowSelection = {
    onChange: (selectedRowKeys, selectedRows) => {
            this.state.nowIds = selectedRowKeys.join(',');
            this.state.selectedRowKeys = selectedRowKeys;
            this.setState({
                selectedRowKeys:this.state.selectedRowKeys,
            })
        },
        getCheckboxProps: record => ({
            disabled:record.receiveStatus !=0,
            receiveStatus: record.receiveStatus,
        }),
        selectedRowKeys:this.state.selectedRowKeys,
    };

@ moveStar this table is encapsulated as a component, and then I added a key to the component and solved it. I read all kinds of selectedRowKeys on the Internet, but I don't understand how to make it clear.


after the operation is completed, set selectedRow: [], selectedKeys: []


getCheckboxProps: record => ({
    disabled: this.props.editStatue,
    checked: (this.props.selectedRowKeys.indexOf(record.Id)>-1?true:false),
}),

use checked

  • Ant-design Tree component issues

    the initial state of an asynchronously loaded tree component is as follows: treeData: +: : : : the problem is: child is not preceded by a + sign (cannot be clicked), but the status isLeaf is set to false Expand to load is expanded, hoping...

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-1be5e30-52e50.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-1be5e30-52e50.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?