入力テキストを画面に印刷するコンポーネントを作成しようとしています。ここでは私が作業しているものを示します。React - _this2.SetStateは関数ではありません
class SearchBar extends Component {
constructor(props) {
super(props);
this.state = { term: '' };
}
render() {
return (
<div className="search-bar">
<input value={this.state.term} onChange={event => this.SetState(event.target.value)} />
The value of input is: {this.state.term}
</div>
);
}
}
しかし、私はクロームコンソールでエラーを取得しておいてください。
bundle.js:19818 Uncaught TypeError: _this2.SetState is not a function
任意のアイデア?私はあなたがこれをバインドする必要があると思う
おかげ
可能な重複の(http://stackoverflow.com/questions/29577977/unable-to-access-react- [イベントハンドラ内のインスタンス(この)と反応アクセスすることができません] instance-this-inside-event-handler) – vijayst