Skip to content

Commit 9403b40

Browse files
committed
Use device frame in fundamentals docs
1 parent 0879460 commit 9403b40

16 files changed

+91
-5
lines changed

versioned_docs/version-7.x/header-buttons.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,12 @@ export default function App() {
107107
</TabItem>
108108
</Tabs>
109109

110+
<div className="device-frame">
111+
110112
![Header button](/assets/fundamentals/header-button.png)
111113

114+
</div>
115+
112116
When we define our button this way, you can't access or update the screen component's state in it. This is pretty important because it's common to want the buttons in your header to interact with the screen that the header belongs to. So, we will look how to do this next.
113117

114118
## Header interaction with its screen component
@@ -230,9 +234,11 @@ export default function App() {
230234
</TabItem>
231235
</Tabs>
232236

237+
<div className="device-frame">
233238
<video playsInline autoPlay muted loop >
234239
<source src="/assets/fundamentals/header-screen-interaction.mp4" />
235240
</video>
241+
</div>
236242

237243
Here we update `headerRight` with a button that has `onPress` handler that can access and update the component's state, since it's defined inside the component. We also specify a placeholder button without `onPress` in the screen's `options` to reserve the header space and avoid a layout shift when `setOptions` replaces it on mount.
238244

versioned_docs/version-7.x/headers.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ export default function App() {
4949
}
5050
```
5151

52+
<div className="device-frame">
53+
5254
![Header title](/assets/fundamentals/header-title.png)
5355

56+
</div>
57+
5458
## Using params in the title
5559

5660
To use params in the title, make `options` a function that returns a configuration object. React Navigation calls this function with `{ navigation, route }` - so you can use `route.params` to access the params:
@@ -229,8 +233,12 @@ export default function App() {
229233
}
230234
```
231235

236+
<div className="device-frame">
237+
232238
![Custom header styles](/assets/fundamentals/header-styles.png)
233239

240+
</div>
241+
234242
There are a couple of things to notice here:
235243

236244
1. On iOS, the status bar text and icons are black by default, which doesn't look great over a dark background. We won't discuss it here, but see the [status bar guide](status-bar.md) to configure it.
@@ -352,8 +360,12 @@ export default function App() {
352360
}
353361
```
354362

363+
<div className="device-frame">
364+
355365
![Header custom title](/assets/fundamentals/header-title-custom.png)
356366

367+
</div>
368+
357369
:::note
358370

359371
`headerTitle` is header-specific, while `title` is also used by tab bars and drawers, or as page title on web. `headerTitle` defaults to displaying the `title` in a `Text` component.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,12 @@ In a typical React Native app, the `NavigationContainer` should be only used onc
128128
</TabItem>
129129
</Tabs>
130130

131+
<div className="device-frame">
132+
131133
![Basic app using stack navigator](/assets/fundamentals/basic-stack.png)
132134

135+
</div>
136+
133137
If you run this code, you will see a screen with an empty navigation bar and a grey content area containing your `HomeScreen` component (shown above). These are the default styles for a stack navigator - we'll learn how to customize them later.
134138

135139
:::tip

versioned_docs/version-7.x/navigating.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,11 @@ export default function App() {
144144
}
145145
```
146146

147+
<div className="device-frame">
147148
<video playsInline autoPlay muted loop>
148149
<source src="/assets/fundamentals/navigate.mp4" />
149150
</video>
151+
</div>
150152

151153
The [`useNavigation`](use-navigation.md) hook returns the navigation object. We can call `navigate` with the route name we want to go to.
152154

@@ -272,9 +274,11 @@ export default function App() {
272274
}
273275
```
274276

277+
<div className="device-frame">
275278
<video playsInline autoPlay muted loop>
276279
<source src="/assets/fundamentals/stack-push.mp4" />
277280
</video>
281+
</div>
278282

279283
Each `push` call adds a new route to the stack, while `navigate` only pushes if you're not already on that route.
280284

@@ -340,9 +344,11 @@ export default function App() {
340344
}
341345
```
342346

347+
<div className="device-frame">
343348
<video playsInline autoPlay muted loop>
344349
<source src="/assets/fundamentals/go-back.mp4" />
345350
</video>
351+
</div>
346352

347353
:::note
348354

@@ -415,9 +421,11 @@ export default function App() {
415421
}
416422
```
417423

424+
<div className="device-frame">
418425
<video playsInline autoPlay muted loop>
419426
<source src="/assets/fundamentals/pop-to-top.mp4" />
420427
</video>
428+
</div>
421429

422430
## Summary
423431

versioned_docs/version-7.x/navigation-lifecycle.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,16 @@ function SettingsStackScreen() {
263263
function Root() {
264264
return (
265265
<MyTabs.Navigator screenOptions={{ headerShown: false }}>
266-
<MyTabs.Screen name="HomeStack" component={HomeStackScreen} options={{ tabBarLabel: 'Home' }} />
267-
<MyTabs.Screen name="SettingsStack" component={SettingsStackScreen} options={{ tabBarLabel: 'Settings' }} />
266+
<MyTabs.Screen
267+
name="HomeStack"
268+
component={HomeStackScreen}
269+
options={{ tabBarLabel: 'Home' }}
270+
/>
271+
<MyTabs.Screen
272+
name="SettingsStack"
273+
component={SettingsStackScreen}
274+
options={{ tabBarLabel: 'Settings' }}
275+
/>
268276
</MyTabs.Navigator>
269277
);
270278
}
@@ -282,9 +290,11 @@ export default function App() {
282290
</TabItem>
283291
</Tabs>
284292

293+
<div className="device-frame">
285294
<video playsInline autoPlay muted loop>
286295
<source src="/assets/fundamentals/lifecycle.mp4" />
287296
</video>
297+
</div>
288298

289299
We start on the `HomeScreen` and navigate to `DetailsScreen`. Then we use the tab bar to switch to the `SettingsScreen` and navigate to `ProfileScreen`. After this sequence of operations is done, all 4 of the screens are mounted! If you use the tab bar to switch back to the `HomeStack`, you'll notice you'll be presented with the `DetailsScreen` - the navigation state of the `HomeStack` has been preserved!
290300

@@ -618,9 +628,11 @@ export default function App() {
618628
</TabItem>
619629
</Tabs>
620630

631+
<div className="device-frame">
621632
<video playsInline autoPlay muted loop>
622633
<source src="/assets/fundamentals/focus-effect.mp4" />
623634
</video>
635+
</div>
624636

625637
To render different things based on whether the screen is focused, we can use the [`useIsFocused`](use-is-focused.md) hook which returns a boolean indicating whether the screen is focused.
626638

versioned_docs/version-7.x/params.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,11 @@ export default function App() {
9898
}
9999
```
100100

101+
<div className="device-frame">
101102
<video playsInline autoPlay muted loop>
102103
<source src="/assets/fundamentals/passing-params.mp4" />
103104
</video>
105+
</div>
104106

105107
## Initial params
106108

@@ -278,9 +280,11 @@ export default function App() {
278280
}
279281
```
280282
283+
<div className="device-frame">
281284
<video playsInline autoPlay muted loop>
282285
<source src="/assets/fundamentals/passing-params-back.mp4" />
283286
</video>
287+
</div>
284288
285289
After pressing "Done", the home screen's `route.params` will be updated with the post text.
286290

versioned_docs/version-8.x/auth-flow.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,5 +1002,6 @@ const RootStack = createNativeStackNavigator({
10021002
The `routeNamesChangeBehavior` option allows you to control how React Navigation handles navigation when the available screens change because of conditions such as authentication state. When `lastUnhandled` is specified, React Navigation will remember the last screen that couldn't be handled, and after the condition changes, it'll automatically navigate to that screen if it's now available.
10031003

10041004
<video playsInline autoPlay muted loop style={{ width: '500px', aspectRatio: 1 / 1 }}>
1005+
10051006
<source src="/assets/deep-linking/deep-link-auth.mp4" />
10061007
</video>

versioned_docs/version-8.x/elements.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,9 +722,7 @@ It can also be a function that returns a React Element to render any component:
722722

723723
```js
724724
<HeaderBackButton
725-
icon={({ tintColor }) => (
726-
<MyCustomBackIconComponent tintColor={tintColor} />
727-
)}
725+
icon={({ tintColor }) => <MyCustomBackIconComponent tintColor={tintColor} />}
728726
onPress={() => console.log('back pressed')}
729727
/>
730728
```

versioned_docs/version-8.x/header-buttons.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ export default function App() {
5555
}
5656
```
5757

58+
<div className="device-frame">
59+
5860
![Header button](/assets/fundamentals/header-button.png)
5961

62+
</div>
63+
6064
When we define our button this way, you can't access or update the screen component's state in it. This is pretty important because it's common to want the buttons in your header to interact with the screen that the header belongs to. So, we will look how to do this next.
6165

6266
## Header interaction with its screen component
@@ -117,9 +121,11 @@ export default function App() {
117121
}
118122
```
119123

124+
<div className="device-frame">
120125
<video playsInline autoPlay muted loop >
121126
<source src="/assets/fundamentals/header-screen-interaction.mp4" />
122127
</video>
128+
</div>
123129

124130
Here we update `headerRight` with a button that has `onPress` handler that can access and update the component's state, since it's defined inside the component. We also specify a placeholder button without `onPress` in the screen's `options` to reserve the header space and avoid a layout shift when `setOptions` replaces it on mount.
125131

versioned_docs/version-8.x/headers.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,12 @@ export default function App() {
5252
}
5353
```
5454

55+
<div className="device-frame">
56+
5557
![Header title](/assets/fundamentals/header-title.png)
5658

59+
</div>
60+
5761
## Using params in the title
5862

5963
To use params in the title, make `options` a function that returns a configuration object. React Navigation calls this function with `{ navigation, route }` - so you can use `route.params` to access the params:
@@ -235,8 +239,12 @@ export default function App() {
235239
}
236240
```
237241

242+
<div className="device-frame">
243+
238244
![Custom header styles](/assets/fundamentals/header-styles.png)
239245

246+
</div>
247+
240248
There are a couple of things to notice here:
241249

242250
1. On iOS, the status bar text and icons are black by default, which doesn't look great over a dark background. We won't discuss it here, but see the [status bar guide](status-bar.md) to configure it.
@@ -358,8 +366,12 @@ export default function App() {
358366
}
359367
```
360368

369+
<div className="device-frame">
370+
361371
![Header custom title](/assets/fundamentals/header-title-custom.png)
362372

373+
</div>
374+
363375
:::note
364376

365377
`headerTitle` is header-specific, while `title` is also used by tab bars and drawers, or as page title on web. `headerTitle` defaults to displaying the `title` in a `Text` component.

0 commit comments

Comments
 (0)