Can anyone help me, I am getting this error "App.js:69 Uncaught TypeError: Cannot read properties of undefined (reading ‘setState’)
at onInputChange (App.js:69:1)"
Code Snippet
>Solution :
Few ways to go about this.
Since you’re not using arrow function you need to bind your handlers
constructor() {
...code
this.onInputChange = this.onInputChange.bind(this)
this.onButtonSubmit = this.onInputChange.bind(this)
}
option 2 – switch your function to arrow function
onInputChange = (event) => {
...code
}
onButtonSubmit = () => {
...code
}
Here’s a helpful post to help you understand why