Improve the BackAndroid example to be more clear

Summary:
The example of `BackAndroid` caused a bit of confusion for beginners (see #8822), so I thought we should clarify the functionality a bit. I added a comment indicating that a user would have to implement `this.onMainScreen` and `this.goBack` on their own, this was the original problem.
Closes https://github.com/facebook/react-native/pull/8829

Differential Revision: D3660332

fbshipit-source-id: d84a29586c6a1a439f386e6b88220d7b0a275129
This commit is contained in:
Daniel Schmidt 2016-08-02 18:16:02 -07:00 committed by Facebook Github Bot 8
parent 1a690d5674
commit c2cf510ff8
1 changed files with 9 additions and 6 deletions

View File

@ -44,13 +44,16 @@ RCTDeviceEventEmitter.addListener(DEVICE_BACK_EVENT, function() {
*
* Example:
*
* ```js
* ```javascript
* BackAndroid.addEventListener('hardwareBackPress', function() {
* if (!this.onMainScreen()) {
* this.goBack();
* return true;
* }
* return false;
* // this.onMainScreen and this.goBack are just examples, you need to use your own implementation here
* // Typically you would use the navigator here to go to the last state.
*
* if (!this.onMainScreen()) {
* this.goBack();
* return true;
* }
* return false;
* });
* ```
*/