I face a question as flow:
class App extends React.Component {
testop(){
alert("test");
}
showAlert() {
// alert("Im an alert");
this.testop();
}
render() {
return <button onClick={this.showAlert}>show alert</button>;
}
}
when I run the code, the error is "Uncaught TypeError: Cannot read properties of undefined (reading 'testop')". why cannot read testop function?