Skip to content

Commit

Permalink
fix(initial values): initial values
Browse files Browse the repository at this point in the history
  • Loading branch information
titanve committed Mar 3, 2019
1 parent cf3f784 commit 2d85557
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/react-next-paging.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class ReactNextPaging extends React.Component {

constructor(props) {
super(props);
this.state = this.generateStateFromProps(props);
const newState = this.generateStateFromProps(props);
this.state = { ...newState };
}

static defaultProps = {
Expand All @@ -77,11 +78,12 @@ class ReactNextPaging extends React.Component {
) {
const { currentpage } = prevState;
const newState = this.generateStateFromProps(this.props, currentpage);
this.setState({ newState });
this.setState({ ...newState });
}
}

generateStateFromProps = (props, currentpage = 1) => {
console.log("generateStateFromProps");
const { items, itemsperpage, pagesspan } = props;
let newnopages = getNoPages(items, itemsperpage);
let newcurrentpage = currentpage;
Expand Down

0 comments on commit 2d85557

Please sign in to comment.