-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
47 lines (40 loc) · 1.35 KB
/
App.js
File metadata and controls
47 lines (40 loc) · 1.35 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
import * as SplashScreen from "expo-splash-screen";
import { useMigrations } from "drizzle-orm/expo-sqlite/migrator";
import MainApp from "./src/MainApp";
import migrations from "./drizzle/migrations";
import { db } from "./src/db/client";
import { Text, View } from "react-native";
import { useCallback } from "react";
// Keep the splash screen visible while we fetch resources
SplashScreen.preventAutoHideAsync();
export default function App() {
const { success, error } = useMigrations(db, migrations);
const onLayoutRootView = useCallback(async () => {
if (success) {
// This tells the splash screen to hide immediately! If we call this after
await SplashScreen.hideAsync();
}
}, [success]);
// The error and !success clauses can be removed or at least logged
// to the backedn for better trackeing before going to prod
if (error) {
console.log('error en migration',error);
return (
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
<Text>Migration erreur: {error.message}</Text>
</View>
);
}
if (!success) {
return (
<View style={{ flex: 1, alignItems: "center", justifyContent: "center" }}>
<Text>Migration en cours...</Text>
</View>
);
}
return (
<View style={{ flex: 1 }} onLayout={onLayoutRootView}>
<MainApp />
</View>
);
}