You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/custom-android-back-button-handling.md
+1-126Lines changed: 1 addition & 126 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,19 +4,13 @@ title: Custom Android back button behavior
4
4
sidebar_label: Android back button behavior
5
5
---
6
6
7
-
import Tabs from '@theme/Tabs';
8
-
import TabItem from '@theme/TabItem';
9
-
10
7
By default, when user presses the Android hardware back button, react-navigation will pop a screen or exit the app if there are no screens to pop. This is a sensible default behavior, but there are situations when you might want to implement custom handling.
11
8
12
9
As an example, consider a screen where user is selecting items in a list, and a "selection mode" is active. On a back button press, you would first want the "selection mode" to be deactivated, and the screen should be popped only on the second back button press. The following code snippet demonstrates the situation. We make use of [`BackHandler`](https://reactnative.dev/docs/backhandler.html) which comes with react-native, along with the `useFocusEffect` hook to add our custom `hardwareBackPress` listener.
13
10
14
11
Returning `true` from `onBackPress` denotes that we have handled the event, and react-navigation's listener will not get called, thus not popping the screen. Returning `false` will cause the event to bubble up and react-navigation's listener will pop the screen.
15
12
16
-
<TabsgroupId="config"queryString="config">
17
-
<TabItemvalue="static"label="Static"default>
18
-
19
-
```js name="Custom android back button" snack
13
+
```js name="Custom android back button" snack static2dynamic
The presented approach will work well for screens that are shown in a `StackNavigator`. Custom back button handling in other situations may not be supported at the moment (eg. A known case when this does not work is when you want to handle back button press in an open drawer. PRs for such use cases are welcome!).
249
124
250
125
If instead of overriding system back button, you'd like to prevent going back from the screen, see docs for [preventing going back](preventing-going-back.md).
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/custom-navigators.md
-3Lines changed: 0 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,6 @@ title: Custom navigators
4
4
sidebar_label: Custom navigators
5
5
---
6
6
7
-
import Tabs from '@theme/Tabs';
8
-
import TabItem from '@theme/TabItem';
9
-
10
7
In essence, a navigator is a React component that takes a set of screens and options, and renders them based on its [navigation state](navigation-state.md), generally with additional UI such as headers, tab bars, or drawers.
11
8
12
9
React Navigation provides a few built-in navigators, but they might not always fit your needs if you want a very custom behavior or UI. In such cases, you can build your own custom navigators using React Navigation's APIs.
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/customizing-bottom-tabs.md
-3Lines changed: 0 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,6 @@ title: Customizing bottom tab bar
4
4
sidebar_label: Customizing tab bar
5
5
---
6
6
7
-
import Tabs from '@theme/Tabs';
8
-
import TabItem from '@theme/TabItem';
9
-
10
7
This guide covers customizing the tab bar in [`createBottomTabNavigator`](bottom-tab-navigator.md). Make sure to install and configure the library according to the [installation instructions](bottom-tab-navigator.md#installation) first.
Copy file name to clipboardExpand all lines: versioned_docs/version-8.x/drawer-actions.md
-3Lines changed: 0 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,6 @@ title: DrawerActions reference
4
4
sidebar_label: DrawerActions
5
5
---
6
6
7
-
import Tabs from '@theme/Tabs';
8
-
import TabItem from '@theme/TabItem';
9
-
10
7
`DrawerActions` is an object containing methods for generating actions specific to drawer-based navigators. Its methods expand upon the actions available in [CommonActions](navigation-actions.md).
This doesn't replicate the behavior of the header in stack and native stack navigators as the stack navigator also includes animations, and the native stack navigator header is provided by the native platform.
See the [navigation events guide](navigation-events.md) for more details on the event listener API.
138
83
139
84
In most cases, it's recommended to use the `useFocusEffect` hook instead of adding the listener manually. See below for details.
@@ -144,10 +89,7 @@ React Navigation provides a [hook](use-focus-effect.md) that runs an effect when
144
89
145
90
This is particularly handy when we are trying to stop something when the page is unfocused, like stopping a video or audio file from playing, or stopping the tracking of a user's location.
0 commit comments