Answer the question
In order to leave comments, you need to log in
How to overcome the error Uncaught TypeError: Cannot read property 'validateData' of undefined?
This error occurs in the code:
class Index extends React.Component {
constructor (props, context) {
super(props, context);
this.state = {isHidden: true};
this.validateData = this.validateData.bind(this);
validateData (){
};
sendData() {
//Валидация
this.validateData();
}
Answer the question
In order to leave comments, you need to log in
You need to pass the context to the sendData method. One option in the constructor is to write:this.sendData = this.sendData.bind(this);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question