react-native-useappstate
Version:
React Native AppState hook
55 lines (43 loc) • 964 B
Markdown
event.
<br>
Works with expo! ✌️
```bash
npm install react-native-useappstate
```
```typescript
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;
```
The hook returns an react native AppStateStatus.
<br>
```["active" | "background" | "inactive" | "unknown" | "extension" | null]```
```typescript
import { AppStateStatus } from "react-native";
```
A hook that listens to react native AppState change