O'Reilly logo

React Router Quick Start Guide by Sagar Ganatra

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

Adding the <NativeRouter> component

Let's now add the react-router-native package to the application that we just created:

    npm install --save react-router-native

The NativeRouter component is used in React Native applications to provide routing and navigation support. It enables components such as <Route> and <Link> to be used in the native application. 

Let's first create a side menu that includes a couple of <Link> components: 

import { Link } from 'react-router-native';export class Menu extends Component {    render() {        return (            <ScrollView scrollsToTop={false} style={styles.menu}>                <View>                    <Link to="/">                        <Text>Home</Text>                    </Link>                    <Link to="/dashboard">                        <Text>Dashboard</Text>                    </Link>                </View>            </ScrollView>        )    }}

The <ScrollView> component is ...

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