Navigators, scenes, routes, and stacks

The core mechanism you'll use to control navigation in your React Native app is the Navigator component. It's used to control route stacks and scenes. I'll quickly define these concepts here, and then we'll dive into some code.

  • Navigator: The overarching component that's used to control how users navigate through your application
  • Scene: A simple React component that represents what the user is currently looking at. Instead of pressing a link on a page that takes them to another page, the Navigator takes them to another scene
  • Route: A JavaScript object containing information about a scene. The Navigator figures out how to render a scene based on information provided by a route
  • Stack: A stack of routes held by the Navigator. These are all the routes that the user can navigate to in a React Native application

Confused? Don't worry! This will all start to make sense once I start speaking in code: right now.

Note

There are actually two other Navigator components offered by React Native. I'm only covering the generic Navigator component because it works the same on both iOS and Android. But if you're interested, there's NavigatorIOS which is geared toward iOS devices, and NavigatorExperimental, which takes a different approach to handling routing.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset