typeerror setstate is not a function react hooks code example

Example 1: this.setstate is not a function

Make sure you use arrow functions to correctly bind 'this'

 handlePageChange = (page) => {
        this.setState({ currentPage: page });
    }

This will give you 'this.setstate is not a function'

 handlePageChange(page){
        this.setState({ currentPage: page });
    }

Example 2: this.setstate is not a function in react native

constructor(props) {
    super(props)
    this.onClick = this.onClick.bind(this)
}

 onClick () {
     this.setState({...})
 }