1

ユーザーがテキスト フィールドに入力しているときに、テキスト フィールドで検証を実行しようとしています。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} />
        )
    }
}
4

1 に答える 1