react-native-useappstate
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

react-native-useappstate

React Native AppState hook

A hook that listens to react native AppState change event.
Works with expo! ✌️

Installation

npm install react-native-useappstate

Usage

import react from "react";
import {
    View,
    Text
} from "react-native";
import useAppState from "react-native-useappstate";

const App = () => {
    const appState = useAppState();

    return (
        <View
            style={{
                flex: 1,
                justifyContent: "center",
                alignItems: "center"
            }}
        >
            <Text>
                {`Current app state: ${appState}`}
            </Text>
        </View>
    );
}

export default App;

Hook

Returns

The hook returns an react native AppStateStatus.
["active" | "background" | "inactive" | "unknown" | "extension" | null]

import { AppStateStatus } from "react-native";

Package Sidebar

Install

npm i react-native-useappstate

Weekly Downloads

136

Version

1.0.4

License

MIT

Unpacked Size

6.32 kB

Total Files

10

Last publish

Collaborators

  • lukaswass