Answers for "TypeError: this.setstate is not a function"

2

this.setstate is not a function in react native

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

 onClick () {
     this.setState({...})
 }
Posted by: Guest on October-31-2020
0

TypeError: 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 });
    }
Posted by: Guest on October-25-2021

Code answers related to "TypeError: this.setstate is not a function"

Code answers related to "Javascript"

Browse Popular Code Answers by Language