1.0.0 • Published 8 years ago
react-native-android-back-component v1.0.0
android-back-button
At a Glance
android-back-button is a React Native module for hardware back button on Android devices. Component listens for press event and provides developer with simple way to manage it. Fully compatible with iOS.
Installation
Via npm:
npm install android-back-button --saveVia yarn:
yarn add android-back-buttonUsage
Simply add AndroidBackButton component to scene's layout:
import React, {
Component
} from 'react';
import {
View
} from 'react-native';
import AndroidBackButton from 'android-back-button';
export default class Scene extends Component {
render() {
const {navigator} = this.props;
return (
<View style={styles.container}>
<AndroidBackButton
onPress={() => {
navigator.pop();
return true;
}}
/>
</View>
);
}
}As you can see in example above, AndroidBackButton component uses onPress property which is a handler for press event on Android hardware back button.
onPress method should return boolean value:
falseif you want to close app;trueif you want to continue using app.
You can implement any custom behavior inside onPress handler which gives you a super-flexible approach for managing navigation inside of app.
License
android-back-button is available under the MIT license. See the LICENSE file for more info.
1.0.0
8 years ago