Expo App Stuck on Splash Screen | Fix
While developing a React Native app with Expo, I encountered an issue where my app would get stuck on the splash screen. This can happen in different scenarios:
- During development in Expo Go
- In production builds
- After upgrading Expo SDK
- In iOS simulator or TestFlight builds
Let me share all the solutions that worked for me and others in the community.
Quick Solutions to Try First
- Clear Expo Cache and Restart
# Clear cache
expo start -c
# If using yarn
yarn start --clear
- Remove node_modules and Reinstall
# Remove existing dependencies
rm -rf node_modules
rm package-lock.json # or yarn.lock if using yarn
# Reinstall
npm install # or yarn install
Common Causes and Solutions
1. React Native Screens Not Installed
One common cause is missing or improperly installed react-native-screens
. Here's how to fix it:
# Install react-native-screens
npx expo install react-native-screens
# Add this import at the top of your App.js/App.tsx
import 'react-native-screens/native-screens';
2. Incorrect Import Statements
Sometimes auto-imports can cause this issue. Check for and fix any incorrect imports:
// ❌ Incorrect import
import { useState } from 'react/cjs/react.development';
// ✅ Correct import
import { useState } from 'react';
3. UUID Resolution Issues
If you're using UUID in your project, remove it from resolutions in package.json:
{
"resolutions": {
// ❌ Remove this if present
"uuid": "^8.3.2"
}
}
4. Modal or Alert on App Launch
If you're showing a modal or alert immediately when the app launches, it can cause the splash screen to hang:
// ❌ Problematic code
const App = () => {
useEffect(() => {
Alert.alert('Welcome!') // This can cause splash screen to hang
}, [])
// ...
}
// ✅ Better approach
const App = () => {
useEffect(() => {
const timer = setTimeout(() => {
Alert.alert('Welcome!')
}, 1000)
return () => clearTimeout(timer)
}, [])
// ...
}
5. Xcode Related Issues (iOS)
If you're facing this on iOS, try:
# Reset Xcode path
sudo xcode-select --reset
# Or set the correct path
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
6. Debug Statements
Remove any debugger statements in your code as they can cause hanging:
// ❌ Remove these
debugger;
console.debug();
Production Build Specific Solutions
1. Clean Build Directories
# For iOS
cd ios
rm -rf build
pod install
# For Android
cd android
./gradlew clean
2. Check SplashScreen Configuration
Make sure your splash screen is properly configured in app.json:
{
"expo": {
"splash": {
"image": "./assets/splash.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
}
}
}
3. Manual Splash Screen Control
If you're manually controlling the splash screen, ensure proper implementation:
import * as SplashScreen from 'expo-splash-screen';
// Keep splash screen visible while we fetch resources
SplashScreen.preventAutoHideAsync();
const App = () => {
const [appIsReady, setAppIsReady] = useState(false);
useEffect(() => {
async function prepare() {
try {
// Pre-load fonts, make API calls, etc.
await loadResourcesAsync();
} catch (e) {
console.warn(e);
} finally {
setAppIsReady(true);
}
}
prepare();
}, []);
const onLayoutRootView = useCallback(async () => {
if (appIsReady) {
await SplashScreen.hideAsync();
}
}, [appIsReady]);
if (!appIsReady) {
return null;
}
return (
<View onLayout={onLayoutRootView}>
{/* Your app content */}
</View>
);
};
Development Environment Fixes
- Update Expo CLI
npm install -g expo-cli@latest
- Update Expo Go App Delete and reinstall the Expo Go app on your device/simulator.
Prevention Tips
To prevent this issue in future:
- Always use the latest stable versions of Expo SDK and dependencies
- Test thoroughly after adding new dependencies
- Keep development environment updated
- Use expo-doctor to check for common issues:
npx expo-doctor
When Nothing Works
If none of the above solutions work:
- Create a new Expo project
- Gradually move your code to the new project
- Compare configurations between working and non-working projects
- Check for differences in dependencies and versions
Remember to always test your app thoroughly after applying any of these fixes, especially before deploying to production.