Skip to content

Commit

Permalink
fix: hide SplashScreen (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidk92 authored Dec 13, 2024
1 parent 5183cc9 commit 6c3bef7
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useEffect, useMemo, useRef, useState, ReactElement } from 'react';
import { useEffect, useMemo, useState, ReactElement } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { RunnerBridge, SherloModule } from '../helpers';
import { Snapshot, StorybookParams, StorybookView } from '../types';
import { SherloContext } from './contexts';
import generateStorybookComponent from './generateStorybookComponent';
import { useOriginalMode, useStoryEmitter, useTestingMode } from './hooks';
import { useHideSplashScreen, useOriginalMode, useStoryEmitter, useTestingMode } from './hooks';
import { setupErrorSilencing } from './utils';
import { Layout } from './components';

Expand All @@ -32,6 +32,8 @@ function getStorybook(view: StorybookView, params?: StorybookParams): () => Reac
},
});

useHideSplashScreen();

// Testing mode
useTestingMode(view, mode, setSnapshots, setTestedIndex, RunnerBridge);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as useHideSplashScreen } from './useHideSplashScreen';
export { default as useOriginalMode } from './useOriginalMode';
export { default as useStoryEmitter } from './useStoryEmitter';
export { default as useTestingMode } from './useTestingMode';
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { useEffect } from 'react';

const hideSplashScreens: (() => void)[] = [];

try {
const ExpoSplashScreen = require('expo-splash-screen');

hideSplashScreens.push(() => {
try {
ExpoSplashScreen.hide();
} catch {
try {
ExpoSplashScreen.hideAsync();
} catch {}
}
});
} catch {
// No expo-splash-scree package available
}

try {
const RNSplashScreen = require('react-native-splash-screen');

hideSplashScreens.push(() => {
try {
RNSplashScreen.hide();
} catch {}
});
} catch {
// No react-native-splash-screen package available
}

try {
const BootSplash = require('react-native-bootsplash');

hideSplashScreens.push(() => {
try {
BootSplash.hide();
} catch {}
});
} catch {
// No react-native-bootsplash package available
}

export function useHideSplashScreen() {
useEffect(() => {
hideSplashScreens.forEach((hide) => hide());
}, []);
}

export default useHideSplashScreen;

0 comments on commit 6c3bef7

Please sign in to comment.