私はaxios
ポストを使用してモーダルを隠す/表示しようとしています。私は、エラーを取得未定義のプロパティ '非表示を読み取ることができません還元モーメントを使用してモーダルを表示しない
アイデア?
// dispatch to hide modal
hide() {
this.props.dispatch(hideModal());
}
// dispatch to show modal
show() {
this.props.dispatch(
showError({
type: 'SHOW_MODAL',
modalType: 'SHOW_LOADING',
modalProps: {
onClose: hideModal,
text: 'Please complete all fields',
},
})
);
}
submitForm(UserDetails) {
this.show();
axios
.post('http://localhost:3001/api/users', UserDetails)
.then(function(response) {
this.hide();
})
.catch(function(error) {
console.log(error);
});
}
あなたが提案した2番目の解決策はうまくいかないと思いますが、ここでは問題を引き起こす 'axios'' this'の問題です。 –
私は同意しますが、私はそれが正しいと思います。 、しかし、通常の機能()でそれは動作しません... –