1Make sure you use arrow functions to correctly bind 'this'
2
3 handlePageChange = (page) => {
4 this.setState({ currentPage: page });
5 }
6
7This will give you 'this.setstate is not a function'
8
9 handlePageChange(page){
10 this.setState({ currentPage: page });
11 }
1constructor(props) {
2 super(props)
3 this.onClick = this.onClick.bind(this)
4}
5
6 onClick () {
7 this.setState({...})
8 }
9