Skip to content

Commit

Permalink
Fixed #1003 - DataTable has null state under certain conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Sep 9, 2019
1 parent dbcf1d5 commit 4202e89
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/components/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,29 +192,25 @@ export class DataTable extends Component {

constructor(props) {
super(props);
let state = {};
this.state = {};

if (!this.props.onPage) {
state.first = props.first;
state.rows = props.rows;
this.state.first = props.first;
this.state.rows = props.rows;
}

if (!this.props.onSort) {
state.sortField = props.sortField;
state.sortOrder = props.sortOrder;
state.multiSortMeta = props.multiSortMeta;
this.state.sortField = props.sortField;
this.state.sortOrder = props.sortOrder;
this.state.multiSortMeta = props.multiSortMeta;
}

if (!this.props.onFilter) {
state.filters = props.filters;
this.state.filters = props.filters;
}

if (this.isStateful()) {
this.restoreState(state);
}

if (Object.keys(state).length) {
this.state = state;
this.restoreState(this.state);
}

this.onPageChange = this.onPageChange.bind(this);
Expand Down Expand Up @@ -1200,6 +1196,7 @@ export class DataTable extends Component {
let columns = React.Children.toArray(this.props.children);

if(columns && columns.length) {
debugger;
if(this.props.reorderableColumns && this.state.columnOrder) {
let orderedColumns = [];
for(let columnKey of this.state.columnOrder) {
Expand Down

0 comments on commit 4202e89

Please sign in to comment.