Summary:
This fixes issues #18954 and #15497
The transformation from Set to (an reversed) Array does not work on Android devices when the remote debugging was started with `react-native run-android`.
<!--
Required: Write your motivation here.
If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.
-->
Add the following code to your App.js and run the app with `react-native run-android` in an Android device:
```
componentDidMount() {
BackHandler.addEventListener('hardwareBackPress', () => {
console.warn('Callback called. Do not close app. Do nothing at all.');
return true; // Do not close the app.
});
}
```
After adding this, the app should NOT close when you press the back button. Without this fix, the app closes (which is the default behaviour).
See also the comments from Victoriayangx in #18954 and #15497.
<!--
Does this PR require a documentation change?
Create a PR at https://github.com/facebook/react-native-website and add a link to it here.
-->
<!--
Required.
Help reviewers and the release process by writing your own release notes. See below for an example.
-->
[ANDROID] [BUGFIX] [BackHandler] - Fix that BackHandler was not called on Android
<!--
**INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.**
CATEGORY
[----------] TYPE
[ CLI ] [-------------] LOCATION
[ DOCS ] [ BREAKING ] [-------------]
[ GENERAL ] [ BUGFIX ] [ {Component} ]
[ INTERNAL ] [ ENHANCEMENT ] [ {Filename} ]
[ IOS ] [ FEATURE ] [ {Directory} ] |-----------|
[ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} |
[----------] [-------------] [-------------] |-----------|
EXAMPLES:
[IOS] [BREAKING] [FlatList] - Change a thing that breaks other things
[ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput
[CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with
[DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word
[GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position
[INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see
-->
Pull Request resolved: https://github.com/facebook/react-native/pull/19077
Reviewed By: yns88
Differential Revision: D9692298
Pulled By: hramos
fbshipit-source-id: 4526b07a4924055ebc9c42e02615c27aa5c97fbb