in example/src/useAppState.ts [18:29]
function handleAppStateChange(nextAppState: AppStateStatus) {
if (nextAppState === 'active' && appState !== 'active') {
onForeground?.();
} else if (
appState === 'active' &&
nextAppState.match(/inactive|background/)
) {
onBackground?.();
}
setAppState(nextAppState);
onChange?.(nextAppState);
}