0
私は、イベントハンドラからmutate関数を呼び出して、catch節でthis.setStateを使用しようとするとInvariant Violationエラーが発生します。Apolloの突然変異コールバックの不変違反設定状態
saveToken({data}){
let {userId, token, expires} = data.login;
storeLoginToken(userId, token, expires);
history.push('/dogs');
}
setErrors(error){
this.setState('error', error.graphQLErrors);
}
handleSubmit(event) {
event.preventDefault();
let {email, password} = this.state;
let {history} = this.props;
let clientKey = getClientKey();
this.props.mutate({ variables: { email, password, clientKey } })
.then(this.saveToken.bind(this))
.catch(this.setErrors.bind(this))
}
愚かな間違い、感謝 –