Skip to content

Commit 69741ec

Browse files
committed
Minor tweaks
1 parent 00cd58d commit 69741ec

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function HomeScreen({ navigation }) {
6767
<Button onPress={() => setCount(c => c + 1)} title="Update count" />
6868
),
6969
});
70-
}, [navigation, setCount]);
70+
}, [navigation]);
7171

7272
return <Text>Count: {count}</Text>;
7373
}
@@ -79,15 +79,16 @@ function HomeScreen({ navigation }) {
7979

8080
You can change the label behavior with `headerBackTitle` and `headerTruncatedBackTitle` ([read more](stack-navigator.md#headerbacktitle)).
8181

82-
To customize the back button image, you can use [headerBackImage](/docs/stack-navigator/#headerbackimage).
82+
To customize the back button image, you can use [headerBackImage](stack-navigator.md#headerbackimage).
8383

8484
## Overriding the back button
8585

8686
The back button will be rendered automatically in a stack navigator whenever it is possible for the user to go back from their current screen &mdash; in other words, the back button will be rendered whenever there is more than one screen in the stack.
8787

88-
Generally, this is what you want. But it's possible that in some circumstances that you want to customize the back button more than you can through the options mentioned above, in which case you can set the `headerLeft` option to a React Element that will be rendered, just as we did with `headerRight`. Alternatively, the `headerLeft` option also accepts a React Component, which can be used, for example, for overriding the onPress behavior of the back button. Read more about this in the [api reference](/docs/stack-navigator/#headerleft).
88+
Generally, this is what you want. But it's possible that in some circumstances that you want to customize the back button more than you can through the options mentioned above, in which case you can set the `headerLeft` option to a React Element that will be rendered, just as we did with `headerRight`. Alternatively, the `headerLeft` option also accepts a React Component, which can be used, for example, for overriding the onPress behavior of the back button. Read more about this in the [api reference](stack-navigator.md#headerleft).
8989

9090
## Summary
9191

9292
- You can set buttons in the header through the `headerLeft` and `headerRight` properties in `options`.
9393
- The back button is fully customizable with `headerLeft`, but if you just want to change the title or image, there are other `options` for that &mdash; `headerBackTitle`, `headerTruncatedBackTitle`, and `headerBackImage`.
94+
- You can use a callback for the options prop to access `navigation` and `route` objects.

versioned_docs/version-5.x/screen-options-resolution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
id: screen-options-resolution
3-
title: Screen options resolution
4-
sidebar_label: Screen options resolution
3+
title: Screen options with nested navigators
4+
sidebar_label: Screen options with nested navigators
55
---
66

77
In this document we'll explain how [screen options](screen-options.md) work when there are multiple navigators. It's important to understand this so that you put your `options` in the correct place and can properly configure your navigators. If you put them in the wrong place, at best nothing will happen and at worst something confusing and unexpected will happen.

versioned_docs/version-5.x/server-rendering.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,10 @@ ctx.status = status.code;
199199

200200
After we render the app with `ReactDOMServer.renderToString`, the `code` property of the `status` object will be updated to be `404` if the `NotFound` screen was rendered.
201201

202-
You can follow a similar approach for other status codes too.
202+
You can follow a similar approach for other status codes too, for example, `401` for unauthorized etc.
203203

204204
## Summary
205205

206206
- Use the `location` prop on `ServerContainer` to render correct screens based on the incoming request.
207207
- Attach a `ref` to the `ServerContainer` get options for the current screen.
208+
- Use context to attach more information such as status code.

versioned_docs/version-5.x/stack-navigator.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,29 @@ Function which returns a React Element to display on the right side of the heade
202202

203203
Function which returns a React Element to display on the left side of the header. When a function is used, it receives a number of arguments when rendered (`onPress`, `label`, `labelStyle` and more - check [types.tsx](https://github.com/react-navigation/react-navigation/blob/master/packages/stack/src/types.tsx#L344-L408) for the complete list).
204204

205+
By default, `HeaderBackButton` component is used. You can implement it and use it to override the back button press, for example:
206+
207+
```js
208+
import { HeaderBackButton } from '@react-navigation/stack';
209+
210+
// ...
211+
212+
<Screen
213+
name="Home"
214+
component={HomeScreen}
215+
options={{
216+
headerLeft: (props) => (
217+
<HeaderBackButton
218+
{...props}
219+
onPress={() => {
220+
// Do something
221+
}}
222+
/>
223+
),
224+
}}
225+
/>;
226+
```
227+
205228
#### `headerStyle`
206229

207230
Style object for the header. You can specify a custom background color here, for example.
@@ -392,7 +415,7 @@ Example:
392415

393416
```js
394417
React.useEffect(() => {
395-
const unsubscribe = navigation.addListener('transitionStart', e => {
418+
const unsubscribe = navigation.addListener('transitionStart', (e) => {
396419
// Do something
397420
});
398421

@@ -408,7 +431,7 @@ Example:
408431

409432
```js
410433
React.useEffect(() => {
411-
const unsubscribe = navigation.addListener('transitionEnd', e => {
434+
const unsubscribe = navigation.addListener('transitionEnd', (e) => {
412435
// Do something
413436
});
414437

0 commit comments

Comments
 (0)