-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
105 lines (87 loc) · 2.59 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import React, { useCallback, useEffect, useState } from 'react';
import { LogBox, useColorScheme, View } from 'react-native';
import { ThemeProvider } from 'styled-components/native';
import Constants from 'expo-constants';
import * as SplashScreen from 'expo-splash-screen';
import { AuthProvider, I18nProvider } from 'src/contexts';
import { loadFonts } from 'src/utils';
import { DarkTheme, LightTheme, THEMES } from 'src/constants/styles';
import RootNavigation from 'src/navigations/RootNavigation';
import * as Storybook from './.storybook';
SplashScreen.preventAutoHideAsync();
const App = () => {
const [appIsReady, setAppIsReady] = useState(false);
const colorScheme = useColorScheme();
const theme = colorScheme === THEMES.DARK ? DarkTheme : LightTheme;
useEffect(() => {
async function prepare() {
try {
await loadFonts();
} catch (e) {
console.warn(e);
} finally {
setAppIsReady(true);
}
}
prepare();
}, []);
const onLayoutRootView = useCallback(async () => {
if (appIsReady) {
await SplashScreen.hideAsync();
}
}, [appIsReady]);
if (!appIsReady) {
return null;
}
return (
<ThemeProvider theme={theme}>
<AuthProvider>
<I18nProvider>
<View style={{ flex: 1 }} onLayout={onLayoutRootView}>
<RootNavigation />
</View>
</I18nProvider>
</AuthProvider>
</ThemeProvider>
);
};
let AppEntryPoint = App;
if (Constants.expoConfig?.extra?.storybookEnabled) {
SplashScreen.hideAsync();
AppEntryPoint = Storybook.default;
}
LogBox.ignoreLogs([
'fontFamily',
'Expected style',
'Node of type rule not supported as an inline style',
'Warning: TNodeChildrenRenderer:',
'Warning: MemoizedTNodeRenderer:',
'Warning: TRenderEngineProvider:',
'You seem to update props of the "TRenderEngineProvider" component',
]);
// Ignore warnings about defaultProps
const errors = console.error;
console.error = (...args) => {
if (
args[0].includes(
'Support for defaultProps will be removed',
'You seem to update props of the "TRenderEngineProvider" component'
)
) {
return;
}
errors(...args);
};
// Ignore defaultProps warning for react-native-render-html
const warnings = console.warn;
console.warn = (...args) => {
if (
args[0].includes(
'You seem to update props of the "TRenderEngineProvider" component in short periods of time'
)
) {
return;
}
warnings(...args);
};
export default AppEntryPoint;