O'Reilly logo

React Native By Example by Richard Kho

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Navigator example

The following code is an example for Navigator:

// index.android.jsimport React, { Component } from 'react'; import {   AppRegistry,   Navigator, } from 'react-native'; import TasksList from './app/components/TasksList'; import EditTask from './app/components/EditTask'; class Tasks extends Component {   render () {     const routes = [       { title: 'Tasks', index: 0 },       { title: 'Edit Task', index: 1 }     ]; 

Again, establish routes for our app.

    return (       <Navigator         initialRoute={{ index: 0}}         renderScene={ (routes, navigator) =>        this._renderScene(routes, navigator) }/>     );   } 

Import the Navigator component and render it for the user. It starts at index:0, which returns the TasksList component.

It returns TasksList if the index ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required