1
我使用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'));
我不知道如何解決這個問題。
你的代碼是工作的罰款。我已經測試過,沒有看到任何警告或錯誤。 –