-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
40 lines (34 loc) · 1.11 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import React, { useState, useEffect, useRef } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import AuthStack from './Navigation/AuthStack';
import { AppState } from 'react-native';
import { freezeTimer } from './screens/FocusTimer';
const App = () => {
const appState = useRef(AppState.currentState);
const [appStateVisible, setAppStateVisible] = useState(appState.current);
useEffect(() => {
const subscription = AppState.addEventListener("change", nextAppState => {
if (
appState.current.match(/inactive|background/) &&
nextAppState === "active"
) {
console.log("App has come to the foreground!");
} else if (nextAppState === "inactive" || nextAppState === "background") {
freezeTimer();
}
appState.current = nextAppState;
// setAppStateVisible(appState.current);
console.log("AppState", appState.current);
});
return () => {
subscription.remove();
};
}, []);
return(
<NavigationContainer>
{/*<AppStack/>*/}
<AuthStack/>
</NavigationContainer>
)
}
export default App;