mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2026-06-28 21:20:04 +00:00
no more state anti-pattern
This commit is contained in:
@@ -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>{ caption }</Caption>);
|
||||
@@ -94,7 +85,7 @@ class BootstrapTable extends PropsBaseResolver(Component) {
|
||||
selectRow={ headerCellSelectionInfo }
|
||||
/>
|
||||
<Body
|
||||
data={ this.state.data }
|
||||
data={ data }
|
||||
keyField={ keyField }
|
||||
columns={ columns }
|
||||
isEmpty={ this.isEmpty() }
|
||||
|
||||
Reference in New Issue
Block a user