Navigating and Routes

    Each navigator supports different ways of navigating:

    • Stack: push
    • Tabs: navigate
    • Drawer: openDrawer

    When navigating, we typically specify a screen name and optionally parameters, e.g. navigator.push("Screen2", { paramA: "Hello!" }).

    Let's look at how this might work.

    In this example, we navigate from Screen1 to Screen2 by pushing Screen2 onto the stack when a button is pressed.

    Routes

    Within a screen, we have access to the current route and its parameters.

    Hooks

    For components which aren't screens (direct descendants of a navigator), we can access the navigation and route objects using hooks.

    Some developers prefer using these hooks instead of props, even in screen components.

    Want to learn React Native in-depth?

    If you like React Native Express, you'll love my new book, Fullstack React Native: The complete guide to React Native! Throughout the book, we'll build 7 full apps, covering complex topics like navigation, gestures, and native modules. We don't assume any knowledge of React or newer JavaScript language features, so you can dive right in regardless of your experience level. The book comes in PDF, EPUB and MOBI formats.