メイン画面に移動しようとしていて、JSデバッガーがオン(実行中)でもコードが正常に機能しますが、JSデバッガーがオフのときにアプリケーションを実行しようとすると問題が発生します無効にしてください)、その時にログインしようとすると "yield put(NavigationActions.navigate({routeName: 'Main'})));" この作品コードはメイン画面にリダイレクトされていません。 (私は反応し-Reduxの-firebaseとReduxの-サガを統合している)redux-sagaを使用してナビゲーションが機能しない
import { NavigationActions } from 'react-navigation';
import { call, put, takeEvery, take } from 'redux-saga/effects';
import { getFirebase } from 'react-redux-firebase';
export function* watchLoginAsync({email, password}) {
try {
const response = yield getFirebase().login({email,password});
if (response.uid) {
// dispatchToMain();
yield put(NavigationActions.navigate({ routeName: 'Main' }));
// yield put({type: LOGIN_SUCCESS });
} else {
yield put({type: LOGIN_FAIL, error: 'Something went wrong seriously!!'});
}
} catch(err => console.log(err))
}
export default function* watchLogin() {
yield takeEvery(LOGIN_REQUESTING, watchLoginAsync);
}
そして、このstore.jsファイル
const sagaMiddleware = createSagaMiddleware();
const middleware = [ sagaMiddleware ];
const firebaseConfig = {
apiKey: '******',
authDomain: '****',
databaseURL: '****',
projectId: '****',
storageBucket: '****',
messagingSenderId: '****',
};
const reduxFirebaseConfig = {
userProfile: 'users',
enableLogging: true,
enableRedirectHandling: false,
};
// Add redux Firebase to compose
const createStoreWithFirebase = compose(
reactReduxFirebase(fbConfig, reduxFirebaseConfig),
applyMiddleware(...middleware)
)(createStore);
// Add Firebase to reducers
const rootReducer = combineReducers({
firebase: firebaseStateReducer,
......
});
// Create store with reducers and initial state
const initialState = {}
export default createStoreWithFirebase(rootReducer, initialState);
// when calling saga, pass getFirebase
sagaMiddleware.run(Sagas, getFirebase)
注: コード下記の
は私のコードですアプリが動作している間にJSデバッガがiOSシミュレータに接続されていると完全にうまく動作しています。
は、loggerMiddlewareを使用していますか? ..私はエミュレータでいくつかの問題を抱えていました。あなたはエミュレータでアクションをトリガするために画面をクリックする必要があります。もしreduxロガーとデバッグがオンになっていれば... – Vicky
いいえ私はロガーミドルウェアを使用していませんが、私のredux- store.jsファイル 'reduxFirebaseConfig'の何かが間違っているため、これが起こっていると思います –