Ani*_*ita 3 modal-dialog reactjs react-table
我正在使用 react-table,这是我的表:
<ReactTable
data={this.props.data}
columns={[
{
Header: "id",
accessor: "id",
width: 50
},
{
Header: "Name",
accessor: "name",
width: 200
},
{
Header: "",
id: "id",
Cell: ({ row }) => (
<button onClick={e => this.handleButtonClick(e, row)}>
Click Me
</button>
)
}
]}
defaultPageSize={10}
showPaginationBottom
/>
Run Code Online (Sandbox Code Playgroud)
按钮点击后的动作
handleButtonClick = (e, row) => {
this.setState({ visible: true});
return
<Modal
title="title"
visible={this.state.visible}
>
// show data here
</Modal>
};
Run Code Online (Sandbox Code Playgroud)
所以这就是我现在的工作方式,但没有显示模态。谁能帮我这个?我究竟做错了什么?
为什么你用handleButtonClick函数返回模态而不是用函数添加它ReactTable
<ReactTable
data={this.props.data}
columns={[
{
Header: "id",
accessor: "id",
width: 50
},
{
Header: "Name",
accessor: "name",
width: 200
},
{
Header: "",
id: "id",
Cell: ({ row }) => (
<button onClick={e => this.handleButtonClick(e, row)}>
Click Me
</button>
)
}
]}
defaultPageSize={10}
showPaginationBottom
/>
{this.state.visible && <Modal
title="title"
visible={this.state.visible}
>
// show data here
</Modal>}
handleButtonClick = (e, row) => {
this.setState({ visible: true});
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9257 次 |
| 最近记录: |