ユーザーがテキスト フィールドに入力しているときに、テキスト フィールドで検証を実行しようとしています。errorText
その場で属性の状態を変更したい。
Uncaught TypeError: this.setState is not a function
状態を設定しようとするとエラーが発生します。以下の関連コード。
export default class Login extends Component {
constructor(props, context) {
super(props, context);
this.state = {
username: null,
errorCopy: null
};
}
handleChange(e) {
this.setState({errorCopy: 'Generic error copy'});
}
render() {
return(
<TextField
hintText="Username"
value={this.state.username}
onChange={this.handleChange}
errorText={this.state.errorCopy} />
)
}
}