Skip to content

Instantly share code, notes, and snippets.

@RobertFischer
Last active March 7, 2018 21:43
Show Gist options
  • Save RobertFischer/19b3f4745dce22d882d8c9b98846576e to your computer and use it in GitHub Desktop.
Save RobertFischer/19b3f4745dce22d882d8c9b98846576e to your computer and use it in GitHub Desktop.
onClick=>{
() => this.setState({pageNumber:this.state.pageNumber+1})
}
onClick={
() => this.setState(({pageNumber}) => {pageNumber:pageNumber+1})
}
@RobertFischer
Copy link
Author

RobertFischer commented Mar 7, 2018

NOTE

The way increment-per-click is implemented, each time the click the button, they will increment the page number. So if you click 3 times, it'll advance the page from page x to x+3.

For increment-once, this would mean that until the page gets re-rendered, clicking the button 3 times would still just move from x to x+1 -- and it will always be x+1 until it's re-rendered with an updated pageNumber.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment