Skip to content

Commit fda407c

Browse files
authored
Update NavigationService example for v3
I am trying to follow these two doc pages in conjunction: - https://reactnavigation.org/docs/en/app-containers.html - https://reactnavigation.org/docs/en/navigating-without-navigation-prop.html Though the "Navigating without the navigation prop" seems out of date since the introduction of explicit app containers in v3, the **App Containers** page indicates that I can get a ref on the _container_ that functions just like a navigator. After a couple of false starts, I stumbled upon what seems to be the correct setup, but it would have been helpful to start from a working example without having to infer the correct combination. My minimal working example: https://snack.expo.io/@brettdh/navigationservice-and-createappcontainer Possibly related: react-navigation/react-navigation#5252
1 parent 6d5b6ff commit fda407c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

docs/navigating-without-navigation-prop.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,19 @@ You can get access to a navigator through a `ref` and pass it to the `Navigation
1111
```javascript
1212
// App.js
1313

14+
import { createStackNavigator, createAppContainer } from 'react-navigation';
1415
import NavigationService from './NavigationService';
1516

1617
const TopLevelNavigator = createStackNavigator({ /* ... */ })
1718

18-
class App extends React.Component {
19+
const AppContainer = createAppContainer(TopLevelNavigator);
20+
21+
export default class App extends React.Component {
1922
// ...
2023

2124
render() {
2225
return (
23-
<TopLevelNavigator
26+
<AppContainer
2427
ref={navigatorRef => {
2528
NavigationService.setTopLevelNavigator(navigatorRef);
2629
}}

0 commit comments

Comments
 (0)