-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy path_layout.tsx
More file actions
54 lines (44 loc) · 1.28 KB
/
_layout.tsx
File metadata and controls
54 lines (44 loc) · 1.28 KB
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
import { useReactNavigationDevTools } from '@dev-plugins/react-navigation';
import FontAwesome from '@expo/vector-icons/FontAwesome';
import { useFonts } from 'expo-font';
import { SplashScreen, Stack, useNavigationContainerRef } from 'expo-router';
import { useEffect } from 'react';
import { StatusBar } from 'expo-status-bar';
export {
// Catch any errors thrown by the Layout component.
ErrorBoundary,
} from 'expo-router';
// Prevent the splash screen from auto-hiding before asset loading is complete.
SplashScreen.preventAutoHideAsync();
export const unstable_settings = {
initialRouteName: 'index',
};
export default function RootLayout() {
const [loaded, error] = useFonts({
SpaceMono: require('../../assets/fonts/SpaceMono-Regular.ttf'),
...FontAwesome.font,
});
// Expo Router uses Error Boundaries to catch errors in the navigation tree.
useEffect(() => {
if (error) throw error;
}, [error]);
useEffect(() => {
if (loaded) {
SplashScreen.hideAsync();
}
}, [loaded]);
if (!loaded) {
return null;
}
return <RootLayoutNav />;
}
function RootLayoutNav() {
const navigationRef = useNavigationContainerRef();
useReactNavigationDevTools(navigationRef);
return (
<>
<Stack />
<StatusBar style="dark" />
</>
);
}