2020-12-13 22:31:55 +01:00
|
|
|
import * as SplashScreen from 'expo-splash-screen'
|
|
|
|
import React, { useEffect, useState } from 'react'
|
2020-11-23 00:07:32 +01:00
|
|
|
import { AppearanceProvider } from 'react-native-appearance'
|
2020-11-04 22:26:38 +01:00
|
|
|
import { QueryCache, ReactQueryCacheProvider, setConsole } from 'react-query'
|
2020-11-21 13:19:05 +01:00
|
|
|
import { Provider } from 'react-redux'
|
2020-11-29 13:11:23 +01:00
|
|
|
import { PersistGate } from 'redux-persist/integration/react'
|
2020-10-31 21:04:46 +01:00
|
|
|
|
2020-12-13 21:09:21 +01:00
|
|
|
import { Index } from '@root/Index'
|
|
|
|
import { persistor, store } from '@root/store'
|
2020-12-13 14:04:25 +01:00
|
|
|
import ThemeManager from '@utils/styles/ThemeManager'
|
|
|
|
|
2020-11-04 22:26:38 +01:00
|
|
|
const queryCache = new QueryCache()
|
|
|
|
|
|
|
|
setConsole({
|
|
|
|
log: console.log,
|
|
|
|
warn: console.warn,
|
|
|
|
error: console.warn
|
|
|
|
})
|
|
|
|
|
2020-12-11 00:29:22 +01:00
|
|
|
// if (__DEV__) {
|
|
|
|
// const whyDidYouRender = require('@welldone-software/why-did-you-render')
|
|
|
|
// whyDidYouRender(React, {
|
|
|
|
// trackAllPureComponents: true,
|
|
|
|
// trackHooks: true,
|
|
|
|
// hotReloadBufferMs: 1000
|
|
|
|
// })
|
|
|
|
// }
|
2020-11-17 23:57:23 +01:00
|
|
|
|
2020-11-23 00:07:32 +01:00
|
|
|
const App: React.FC = () => {
|
2020-12-13 22:31:55 +01:00
|
|
|
const [appLoaded, setAppLoaded] = useState(false)
|
|
|
|
useEffect(() => {
|
|
|
|
const delaySplash = async () => {
|
|
|
|
try {
|
|
|
|
await SplashScreen.preventAutoHideAsync()
|
|
|
|
} catch (e) {
|
|
|
|
console.warn(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delaySplash()
|
|
|
|
}, [])
|
|
|
|
useEffect(() => {
|
|
|
|
const hideSplash = async () => {
|
|
|
|
try {
|
|
|
|
await SplashScreen.hideAsync()
|
|
|
|
} catch (e) {
|
|
|
|
console.warn(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (appLoaded) {
|
|
|
|
hideSplash()
|
|
|
|
}
|
|
|
|
}, [appLoaded])
|
|
|
|
|
2020-11-23 00:07:32 +01:00
|
|
|
return (
|
|
|
|
<AppearanceProvider>
|
2020-11-29 18:08:31 +01:00
|
|
|
<ReactQueryCacheProvider queryCache={queryCache}>
|
|
|
|
<Provider store={store}>
|
2020-12-13 23:02:54 +01:00
|
|
|
<PersistGate
|
|
|
|
persistor={persistor}
|
|
|
|
onBeforeLift={() => setAppLoaded(true)}
|
|
|
|
>
|
2020-11-29 18:08:31 +01:00
|
|
|
{bootstrapped => {
|
|
|
|
if (bootstrapped) {
|
2020-12-13 14:04:25 +01:00
|
|
|
require('@root/i18n/i18n')
|
2020-11-29 18:08:31 +01:00
|
|
|
return (
|
|
|
|
<ThemeManager>
|
|
|
|
<Index />
|
|
|
|
</ThemeManager>
|
|
|
|
)
|
|
|
|
} else {
|
2020-12-13 22:31:55 +01:00
|
|
|
return null
|
2020-11-29 18:08:31 +01:00
|
|
|
}
|
|
|
|
}}
|
|
|
|
</PersistGate>
|
|
|
|
</Provider>
|
|
|
|
</ReactQueryCacheProvider>
|
2020-11-23 00:07:32 +01:00
|
|
|
</AppearanceProvider>
|
|
|
|
)
|
|
|
|
}
|
2020-10-31 21:04:46 +01:00
|
|
|
|
|
|
|
export default App
|