我如何在antd render方法中定义props

时间:2019-10-20 15:20:31

标签: reactjs antd

我需要在antd表中设置道具handleRemove才能将其传递到另一个组件。我无法从类render方法执行此操作,而且我不知道如何从下面的antd render处理它 这是我的桌子的样子

render() {
        const { handleRemove} = this.props; //This does not work

        return (
            <Table
                dataSource={users}
                columns={
                    [
                        {
                            dataIndex: 'firstName',
                            key: 'firstName',
                            title: 'First Name',
                        },
                        {
                            dataIndex: 'lastName',
                            key: 'lastName',
                            title: 'Last Name',
                        },
                        {
                            key: 'action',
                            render: (text, record) => (
                                <Popconfirm
                                    title="Are you sure you want to remove item?"
                                    onConfirm={() => props.handleRemove(record.id)} // Error is from here
                                >
                                    <Icon className={DANGER} type={DELETE} />
                                </Popconfirm>
                            ),
                            title: 'Action',
                        },
                    ]
                }
                rowKey={record => record.id}
            />
        );
    }

0 个答案:

没有答案