![build status](https://github.com/chooin/react-native-lifecycle/actions/workflows/test.yml/badge.svg?branch=master)
简体中文
yarn add react-native-lifecycle
yarn add @react-navigation/native # >= 5.7.0 or >= 6.0.0
package name |
version |
react-native version |
react-native-lifecycle |
2.0.0+ |
0.65.0+ |
react-native-lifecycle |
1.2.4+ |
0.59.0+ |
Example
import { useAppActive, useAppInactive } from 'react-native-lifecycle';
export default function App() {
// Called when the application switches from the background to the foreground
useAppActive(() => {});
// Called when the application switches from the foreground to background
useAppInactive(() => {});
}
import {
useMount,
useShow,
useHide,
useUnmount,
useResize,
} from 'react-native-lifecycle';
export default function Page() {
// Called when the page or component is mounted
useMount(() => {});
// Called when the page is displayed, or when the application switches from the background to the foreground
useShow(() => {});
// Called when the page is hidden, or when the application switches from the foreground to the background
useHide(() => {});
// Called when the page or component is unmounted
useUnmount(() => {});
// Called after the page window resize
useResize(() => {});
}