我用 React 写了这个演示。我使用 Webpack 来构建这个演示。当我开始演示时,我看到这个错误:
错误:
未捕获的类型错误:超级表达式必须为空或函数,而不是未定义
import React, {Compoment} from 'react';
import ReactDOM from 'react-dom';
class App extends React.Compoment {
constructor(props){
super(props);
this.handleClick = this.handleClick.bind(this);
}
handleClick(){
if(this.myTextInput !=null) {
this.myTextInput.focus();
}
}
render (){
return (
<div>
<input type="text" ref={(ref) => this.myTextInput = ref} />
<input type="button"
value="'Focus the text input"
onClick={this.handleClick}
/>
</div>
);
}
}
ReactDOM.render(<App />, document.getElementById('app'));
我不知道如何解决问题。