1import { View } from 'expo-dev-client-components';
2import * as React from 'react';
3
4import { Splash } from './Splash';
5import { loadFontsAsync } from '../native-modules/DevMenu';
6
7type LoadInitialDataProps = {
8  children: React.ReactElement<any> | React.ReactElement<any>[];
9  loader?: React.ReactElement<any>;
10};
11
12export function LoadInitialData({ children, loader = <Splash /> }: LoadInitialDataProps) {
13  const [isLoading, setIsLoading] = React.useState(true);
14
15  React.useEffect(() => {
16    loadFontsAsync().then(() => {
17      setIsLoading(false);
18    });
19  }, []);
20
21  if (isLoading) {
22    return loader;
23  }
24
25  return <View flex="1">{children}</View>;
26}
27