Sagiv Ofek 567b99a2d8 Docs: add info about calling nav from same level component (#122)
* Use es6 default values for initial state

* Docs: add info about calling nav from same level component

* Docs: add info about calling nav from same level component update
2017-02-03 09:03:26 -08:00

1.8 KiB

Navigators

Navigators allow you define you application's navigation structure. Navigators also render common elements such as headers and tab bars which you can configure.

Under the hood, navigators are plain React components.

Built-in Navigators

react-navigation includes the following functions to help you create navigators:

  • StackNavigator - Renders one screen at a time and provides transitions between screens. When a new screen is opened it is placed on top of the stack.
  • TabNavigator - Renders a tab bar that lets the user switch between several screens
  • DrawerNavigator - Provides a drawer that slides in from the left of the screen

Rendering screens with Navigators

The navigators render application screens which are just React components.

To learn how to create screens, read about:

Calling Navigate on Top Level Component

In case you want to use Navigator from the same level you declare it you can use react's ref option:

const AppNavigator = StackNavigator(SomeAppRouteConfigs);

class App extends React.Component {
  someEvent() {
    // call navigate for AppNavigator here:
    this.navigator && this.navigator.dispatch({ type: 'Navigate', routeName, params });
  }
  render() {
    return (
      <AppNavigator ref={nav => { this.navigator = nav; }} />
    );
  }
}

Please notice that this solution should only be used on the top level navigator.