お疲れ様です。
Redux上でエラーが起きた時に、エラーモーダルを出現させたいと考えています。
Reduxでエラーが起きた時にfunctiononError()
を起動させたいのですが、うまくいかずに困っています。
エラー内容
_this.onError is not a function
ソースコード
actions.js
JavaScript
1export const userCreate = ({ user }) => { 2 return (dispatch) => { 3 firebase.database().ref(`/users/`) 4 .set({ 5 user 6 }) 7 .then(() => { 8 dispatch({ type: 'user_save_success' }); 9 }); 10 }) 11 .catch(err => { 12 this.onError(); 13 }); 14 } 15}
UserCreate.js
・・・ onError() { Alert.alert( 'エラーが発生しました', [ {text: I18n.t('cancel'), onPress: () => console.log('Cancel Pressed'), style: 'cancel'}, ], { cancelable: false } ) } ・・・
おそらくReduxにfunction情報を送る必要があると思うのですが、それがなかなかうまくいかず・・・。すみませんが、どうぞよろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー