Skip to content

6. Drawer

Erik Poort edited this page May 3, 2018 · 3 revisions

Structure

The syntax to show a drawer is a bit different. You have a center view which is required and a left and right view, which are optional.

navigation.start(
  <DrawerView id="hamburger"
    left={<SingleView id="home" screen={Home} />}
    center={<SingleView id="home" screen={Home} />}
    right={<SingleView id="home" screen={Home} />}
  />
);

Calls

Calls are navigator type specific, so you should access them that way as well. It doesn't make sense to call 'push' on a tabbar, so these calls are split up.
You can access the navigation via the props:

this.props.drawer

Because you can nest navigation types, you can also access the navigator by its id (in the example above 'hamburger'):

this.props.hamburger

Open view

This is a call with which you can change any of sides of the menu. For example, add this to a menu (left or right side) that opens a page in the center view:

this.props.drawer.openView("center", <SingleView id="home" screen={Home} />);

Feel free to open any other type of navigation!

Clone this wiki locally