-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
45 lines (37 loc) · 1.33 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
41
42
43
44
45
import React, { useEffect, useState } from 'react'
import { Provider as PaperProvider } from 'react-native-paper'
import AppNavigator from './navigation.component'
import FirstTimeAppNavigator from './firstTimeNavigation.component'
import * as SQLite from 'expo-sqlite'
import * as SplashScreen from 'expo-splash-screen'
import useDatabase from './database/useDatabase'
import { DatabaseContextProvider } from './context/DatabaseContext'
import { AsyncStorage } from 'react-native'
const db = SQLite.openDatabase('SAMPLEDB.db')
console.log('Printing first time in APP.js: ')
console.log(db)
export default function App () {
const [firstTimeUsage, setFirstTimeUsage] = useState(null)
// for development only
const clearAsyncStorage = async () => {
AsyncStorage.clear()
}
// uncomment when you have to clear asyncstorage to check first user screen
// useEffect(() => {
// clearAsyncStorage()
// }, [])
SplashScreen.preventAutoHideAsync()
const [isDBLoadingComplete, t, isFirstTime] = useDatabase(db)
if (isDBLoadingComplete) {
SplashScreen.hideAsync()
return (
<PaperProvider>
<DatabaseContextProvider>
{isFirstTime ? <FirstTimeAppNavigator propDB={db}/> : <AppNavigator propDB={db}/>}
</DatabaseContextProvider>
</PaperProvider>
)
} else {
return null
}
}