react-native-android-back-component

1.0.0 • Public • Published

android-back-button

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 --save

Via yarn:

yarn add android-back-button

Usage

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:

  • false if you want to close app;
  • true if 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.

Package Sidebar

Install

npm i react-native-android-back-component

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • ios_mamu