Common mistakes
This section attempts to outline issues that users frequently encounter when first getting accustomed to using React Navigation and serves as a reference in some cases for error messages.
Explicitly rendering more than one navigator
Most apps should only ever render one navigator inside of a React component, and this is usually somewhere near the root component of your app. This is a little bit counter-intuitive at first but it's important for the architecture of React Navigation.
Here's what you might write in your code -- note that this example would be incorrect:
The correct way to write this would be the following:
Alternatively, the following would also work because it exposes the router
static on AuthenticationScreen
and threads through the navigation
prop:
Assigning navigationOptions to the wrong component
In previous version of React Navigation, the library used to dig through your component tree to find navigationOptions
. This is no longer the case, and only navigationOptions
on screen components of a particular navigator will apply to that navigator. You can read more about this in the Navigation options resolution guide.
Wrapping AppContainer in a View without flex
If you wrap the AppContainer
in a View
, make sure the View
is using flex.