From 4ecf2433d03b57e5e06a95cd5a3c0d13b8ca6427 Mon Sep 17 00:00:00 2001 From: AllenFang Date: Sun, 20 May 2018 16:54:04 +0800 Subject: [PATCH] no more state anti-pattern --- .../react-bootstrap-table2/src/bootstrap-table.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/packages/react-bootstrap-table2/src/bootstrap-table.js b/packages/react-bootstrap-table2/src/bootstrap-table.js index 6967b8e..aa711ff 100644 --- a/packages/react-bootstrap-table2/src/bootstrap-table.js +++ b/packages/react-bootstrap-table2/src/bootstrap-table.js @@ -15,16 +15,6 @@ class BootstrapTable extends PropsBaseResolver(Component) { constructor(props) { super(props); this.validateProps(); - - this.state = { - data: props.data - }; - } - - componentWillReceiveProps(nextProps) { - this.setState({ - data: nextProps.data - }); } render() { @@ -42,6 +32,7 @@ class BootstrapTable extends PropsBaseResolver(Component) { renderTable() { const { + data, columns, keyField, id, @@ -74,7 +65,7 @@ class BootstrapTable extends PropsBaseResolver(Component) { const headerCellSelectionInfo = this.resolveSelectRowPropsForHeader({ onAllRowsSelect: this.props.onAllRowsSelect, selected: this.props.selected, - allRowsSelected: isSelectedAll(this.state.data, this.props.selected) + allRowsSelected: isSelectedAll(data, this.props.selected) }); const tableCaption = (caption && { caption }); @@ -94,7 +85,7 @@ class BootstrapTable extends PropsBaseResolver(Component) { selectRow={ headerCellSelectionInfo } />