How to use the navigation/rootNavigation.router function in navigation

To help you get started, we’ve selected a few navigation examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pillarwallet / pillarwallet / src / reducers / navigationReducer.js View on Github external
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];
github pillarwallet / pillarwallet / src / reducers / navigationReducer.js View on Github external
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;