Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
prevActiveScreen: ?string,
prevActiveScreenParams: Object,
}
export type NavigationReducerAction = {
type: string,
payload: any,
action: {
routeName: string,
params: Object,
},
key: ?string,
}
const initialState = {
...RootNavigation.router.getStateForAction(
RootNavigation.router.getActionForPathAndParams(ONBOARDING_FLOW),
),
activeScreen: null,
prevActiveScreen: null,
prevActiveScreenParams: {},
};
const NAVIGATION_ACTION = 'Navigation';
function navigationReducer(state: NavigationReducerState = initialState, action: NavigationReducerAction) {
if (action.type === SET_INITIAL_ROUTE) {
return { ...state, activeScreen: action.payload };
}
if (action.type && action.type.includes(NAVIGATION_ACTION)) {
const nextState = RootNavigation.router.getStateForAction(action, state) || state;
const newActiveScreen = RootNavigation.router.getPathAndParamsForState(nextState).path.split('/').slice(-1)[0];
prevActiveScreenParams: Object,
}
export type NavigationReducerAction = {
type: string,
payload: any,
action: {
routeName: string,
params: Object,
},
key: ?string,
}
const initialState = {
...RootNavigation.router.getStateForAction(
RootNavigation.router.getActionForPathAndParams(ONBOARDING_FLOW),
),
activeScreen: null,
prevActiveScreen: null,
prevActiveScreenParams: {},
};
const NAVIGATION_ACTION = 'Navigation';
function navigationReducer(state: NavigationReducerState = initialState, action: NavigationReducerAction) {
if (action.type === SET_INITIAL_ROUTE) {
return { ...state, activeScreen: action.payload };
}
if (action.type && action.type.includes(NAVIGATION_ACTION)) {
const nextState = RootNavigation.router.getStateForAction(action, state) || state;
const newActiveScreen = RootNavigation.router.getPathAndParamsForState(nextState).path.split('/').slice(-1)[0];
const prevActiveScreenParams = RootNavigation.router.getPathAndParamsForState(state).params;