0
我的登錄組件出現問題,我使用的是cointainer模式,所以我有一個組件登錄管理api調用和一個管理輸入並警告用戶的DumbLogin關於我的服務器的響應。 我正在使用Axios來做api調用,它使用承諾來做到這一點,我也使用箭頭函數來避免這個問題,那是我在想什麼...... 因爲最後我有React Axios在setState後沒有渲染
TypeError: _this.setState is not a function
我試圖用一個變量self來解決這個問題,但那樣會導致相同的錯誤。
我該怎麼做?
axios(all)
.then((response) => {
console.log(response);
if (response.status === 200){
this.setState({
...this.state,
spin: false,
});
let data = response.data;
this.props.connect(data.username, data.email, data.token, data.partners);
this.props.router.push('panel');
}
}).catch((error) => {
console.log(error.response);
this.setState({
spin: false,
errorLogin: 'Username or password wrong',
});
});
(自旋是布爾通知DumbLogin它應該或不顯示一個微調在等待我的服務器響應)
我不知道這事, 謝啦! 我用thunk結束了:) – Darakt