react-navigation-options-from

1.0.1 • Public • Published

react-navigation-options-from

Get react-navigation options from nested navigators

Created to help preserve functionality of nested navigators when upgrading to react-navigation v2. See react-navigation #4309 for more details.

import getNavigationOptionsFrom from "react-navigation-options-from";

const tabs = {
  MainTab: {
    screen: MyHomeScreen,
    path: '/',
    navigationOptions: {
      ...
    },
  },
  SettingsTab: {
    screen: MySettingsScreen,
    path: '/settings',
    navigationOptions: {
      ...
    },
  },
};

const TabNav = createBottomTabNavigator(tabs, {
  tabBarPosition: 'bottom',
  animationEnabled: false,
  swipeEnabled: false,
});

// everything above remains unchanged
// this line is added to inherit navigation options
TabNav.navigationOptions = getNavigationOptionsFrom(tabs);

const StacksOverTabs = createStackNavigator({
  Root: {
    screen: TabNav,
  },
});

/react-navigation-options-from/

    Package Sidebar

    Install

    npm i react-navigation-options-from

    Weekly Downloads

    3

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    3.18 kB

    Total Files

    4

    Last publish

    Collaborators

    • bakerface