Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hide SplashScreen #46

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading