AppState
优质
小牛编辑
130浏览
2023-12-01
安装
npm install --save universal-appstate
APIS
isAvailable: boolean
当前容器是否支持该特性。
nextAppState: 'active' | 'background'
应用程序显示或隐藏。
示例
import AppState from 'universal-appstate';
console.log(AppState.isAvailable);
console.log(AppState.currentState); // active|background
const _handleAppStateChange = (nextAppState) => {
console.log(nextAppState); // active|background
}
AppState.addEventListener('change', _handleAppStateChange);
AppState.removeEventListener('change', _handleAppStateChange);