Skip to content

Commit 025a88d

Browse files
committed
be explicit about when custom back handling is not easy
1 parent 9a8fd1c commit 025a88d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/custom-android-back-button-handling.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Take, for example, a screen where user is selecting items in a list, and a "sele
1111
Returning `true` from `onBackButtonPressAndroid` denotes that we have handled the event, and react-navigation's lister 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.
1212

1313
```
14-
class ComponentWithCustomBackBehavior extends React.Component {
14+
class ScreenWithCustomBackBehavior extends React.Component {
1515
componentDidMount() {
1616
BackHandler.addEventListener('hardwareBackPress', this.onBackButtonPressAndroid);
1717
}
@@ -30,3 +30,5 @@ class ComponentWithCustomBackBehavior extends React.Component {
3030
};
3131
}
3232
```
33+
34+
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!)

0 commit comments

Comments
 (0)