0
我在事件處理函數中調用mutate函數,並在嘗試在catch子句中使用this.setState時收到不變違例錯誤。Apollo mutate回調中的不變違規設置狀態
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))
}
愚蠢的錯誤,謝謝 –