Skip to content

Commit 03690e1

Browse files
authored
fix: 🐛 Corrige l'erreur Sentry : Current activity not found (#1718)
Closes: #1254
1 parent 45bb865 commit 03690e1

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

front/App.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as Font from "expo-font";
2+
import * as SplashScreen from "expo-splash-screen";
23
import { StatusBar } from "expo-status-bar";
34
import type { FC } from "react";
45
import * as React from "react";
@@ -30,6 +31,9 @@ import {
3031
TrackerUtils,
3132
} from "./src/utils";
3233

34+
// Keep the splash screen visible while we fetch resources
35+
void SplashScreen.preventAutoHideAsync();
36+
3337
setNotificationHandler();
3438
initLocales();
3539
initMonitoring();
@@ -138,17 +142,24 @@ const MainAppContainer: FC = () => {
138142

139143
void init();
140144
// Permet de détecter lorsque l'app change d'état ('active' | 'background' | 'inactive' | 'unknown' | 'extension')
141-
AppState.addEventListener("change", handleAppStateChange);
145+
const subscription = AppState.addEventListener(
146+
"change",
147+
handleAppStateChange
148+
);
142149

143150
return () => {
144-
AppState.removeEventListener("change", handleAppStateChange);
151+
subscription.remove();
145152
};
146153
// eslint-disable-next-line react-hooks/exhaustive-deps
147154
}, []);
148155

149156
useEffect(() => {
150157
if (isLoadingComplete && fontsLoaded && appCounterIsLoaded) {
151-
setScreenCanBeDisplayed(true);
158+
const hideSplashScreen = async () => {
159+
await SplashScreen.hideAsync();
160+
setScreenCanBeDisplayed(true);
161+
};
162+
void hideSplashScreen();
152163
}
153164
}, [isLoadingComplete, fontsLoaded, appCounterIsLoaded]);
154165

front/src/hooks/useCachedResources.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Ionicons } from "@expo/vector-icons";
22
import * as Font from "expo-font";
3-
import * as SplashScreen from "expo-splash-screen";
43
import { useEffect, useState } from "react";
54

65
const useCachedResources = (): boolean => {
@@ -10,8 +9,6 @@ const useCachedResources = (): boolean => {
109
useEffect(() => {
1110
async function loadResourcesAndDataAsync() {
1211
try {
13-
void SplashScreen.preventAutoHideAsync();
14-
1512
// Load fonts
1613
await Font.loadAsync({
1714
...Ionicons.font,
@@ -34,7 +31,6 @@ const useCachedResources = (): boolean => {
3431
console.warn(error);
3532
} finally {
3633
setLoadingComplete(true);
37-
void SplashScreen.hideAsync();
3834
}
3935
}
4036

0 commit comments

Comments
 (0)