私はReactを使ってこのデモを書いています。 Webpackを使ってこのデモを作成します。このデモを開始すると、エラーが表示されます。Reactjs、スーパー式はnullまたは関数のいずれかでなければなりません
エラー:
Uncaught TypeError: Super expression must either be null or a function, not undefined
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'));
私はこの問題を解決する方法がわかりません。次
あなたのコードは正常に動作しています。私はテストしたが、警告やエラーは見られませんでした。 –