Getting the error :
TypeError: Cannot read property 'state' of undefined
I face this error when i am going to get my input state value by event onSubmit()
.
onFormSubmit(event){
event.preventDefault();
console.log(this.state.term);
}
Answer
Use arrow function instead so:
Change
onFormSubmit(event){
event.preventDefault();
console.log(this.state.term);
}
To
onFormSubmit= (event)=>{
event.preventDefault();
console.log(this.state.term);
}
No comments:
Post a Comment