Skip to content

Commit b5947fa

Browse files
committed
Update getting started guide
1 parent 2aa5edb commit b5947fa

File tree

2 files changed

+18
-24
lines changed

2 files changed

+18
-24
lines changed

versioned_docs/version-7.x/getting-started.md

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -147,32 +147,14 @@ There are 2 primary ways to configure the navigators:
147147

148148
### Static configuration
149149

150-
The static configuration API has reduced boilerplate and simplifies things such as TypeScript types and deep linking. If you're starting a new project or are new to React Navigation, this is the **recommended way** to set up your app. If you need more flexibility in the future, you can always mix and match with the dynamic configuration.
150+
The static configuration API lets you write your configuration in an object, and is defined statically, i.e. it cannot change at runtime. This has reduced boilerplate and simplifies things such as TypeScript types and deep linking.
151+
152+
If you're starting a new project or are new to React Navigation, this is the **recommended way** to set up your app. If you need more flexibility in the future, you can always mix and match with the dynamic configuration.
151153

152154
Continue to ["Hello React Navigation"](hello-react-navigation.md?config=static) to start writing some code with the static API.
153155

154156
### Dynamic configuration
155157

156-
The dynamic configuration allows for more flexibility but requires more boilerplate and configuration (e.g. for deep links, typescript etc.).
157-
158-
To get started with dynamic configuration, first, we need to wrap your app in `NavigationContainer`. Usually, you'd do this in your entry file, such as `index.js` or `App.js`:
159-
160-
```js
161-
import * as React from 'react';
162-
// highlight-next-line
163-
import { NavigationContainer } from '@react-navigation/native';
164-
165-
export default function App() {
166-
return (
167-
<NavigationContainer>{/* Rest of your app code */}</NavigationContainer>
168-
);
169-
}
170-
```
171-
172-
:::warning
173-
174-
In a typical React Native app, the `NavigationContainer` should be only used once in your app at the root. You shouldn't nest multiple `NavigationContainer`s unless you have a specific use case for them.
175-
176-
:::
158+
The dynamic configuration API lets you write your configuration in React components, and can change at runtime based on state or props. This allows for more flexibility but requires more boilerplate and configuration for Typescript types, deep linking etc.
177159

178160
Continue to ["Hello React Navigation"](hello-react-navigation.md?config=dynamic) to start writing some code with the dynamic API.

versioned_docs/version-7.x/hello-react-navigation.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ npm install @react-navigation/elements
4242

4343
`createNativeStackNavigator` is a function that takes a configuration object containing the screens and customization options. The screens are React Components that render the content displayed by the navigator.
4444

45-
`createStaticNavigation` is a function that takes the navigator defined earlier and returns a component that can be rendered in the app. It's only called once in the app.
45+
`createStaticNavigation` is a function that takes the navigator defined earlier and returns a component that can be rendered in the app. It's only called once in the app. Usually, we'd render the returned component at the root of our app, which is usually the component exported from `App.js`, `App.tsx` etc., or used with `AppRegistry.registerComponent`, `Expo.registerRootComponent` etc.
4646

4747
```js name="Native Stack Example" snack
4848
// In App.js in a new project
@@ -73,12 +73,18 @@ export default function App() {
7373
}
7474
```
7575

76+
:::warning
77+
78+
In a typical React Native app, the `createStaticNavigation` function should be only used once in your app at the root.
79+
80+
:::
81+
7682
</TabItem>
7783
<TabItem value="dynamic" label="Dynamic">
7884

7985
`createNativeStackNavigator` is a function that returns an object containing 2 properties: `Screen` and `Navigator`. Both of them are React components used for configuring the navigator. The `Navigator` should contain `Screen` elements as its children to define the configuration for routes.
8086

81-
`NavigationContainer` is a component that manages our navigation tree and contains the [navigation state](navigation-state.md). This component must wrap all the navigators in the app. Usually, we'd render this component at the root of our app, which is usually the component exported from `App.js`.
87+
`NavigationContainer` is a component that manages our navigation tree and contains the [navigation state](navigation-state.md). This component must wrap all the navigators in the app. Usually, we'd render this component at the root of our app, which is usually the component exported from `App.js`, `App.tsx` etc., or used with `AppRegistry.registerComponent`, `Expo.registerRootComponent` etc.
8288

8389
```js name="Native Stack Example" snack
8490
// In App.js in a new project
@@ -115,6 +121,12 @@ export default function App() {
115121
}
116122
```
117123

124+
:::warning
125+
126+
In a typical React Native app, the `NavigationContainer` should be only used once in your app at the root. You shouldn't nest multiple `NavigationContainer`s unless you have a specific use case for them.
127+
128+
:::
129+
118130
</TabItem>
119131
</Tabs>
120132

0 commit comments

Comments
 (0)