Last active
March 7, 2018 21:43
-
-
Save RobertFischer/19b3f4745dce22d882d8c9b98846576e to your computer and use it in GitHub Desktop.
Button Click -- https://reactjs.org/docs/react-component.html#setstate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onClick=>{ | |
() => this.setState({pageNumber:this.state.pageNumber+1}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onClick={ | |
() => this.setState(({pageNumber}) => {pageNumber:pageNumber+1}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NOTE
The way
increment-per-click
is implemented, each time the click the button, they will increment the page number. So if you click3
times, it'll advance the page from pagex
tox+3
.For
increment-once
, this would mean that until the page gets re-rendered, clicking the button3
times would still just move fromx
tox+1
-- and it will always bex+1
until it's re-rendered with an updatedpageNumber
.