Profile list rendering, startup time, and bundle size. Configure EAS for production builds.
Performance Profiling
React DevTools Profiler
# Start with dev client
npx expo start --dev-client
# Open DevTools (shake device → "Show DevTools")
# Go to Profiler tab
# Click Record → Interact with app → StopAnalyzing Results
| Metric | What It Means | Target |
|---|---|---|
| Render duration | Time to render component | < 16ms (60fps) |
| Why did it render? | Props/state/context changes | Minimize |
| Ranked chart | Components by render time | Optimize top |
// Add Profiler to measure specific components
import { Profiler } from 'react';
function onRenderCallback(
id: string,
phase: 'mount' | 'update',
actualDuration: number,
baseDuration: number,
startTime: number,
commitTime: number
) {
if (actualDuration > 16) {
console.warn(`Slow render: ${id} took ${actualDuration.toFixed(2)}ms`);
}
}
export function MovieList() {
return (
<Profiler id="MovieList" onRender={onRenderCallback}>
<FlatList ... />
</Profiler>
);
}Why Did You Render
npm install @welldone-software/why-did-you-render// App.tsx or component file
import whyDidYouRender from '@welldone-software/why-did-you-render';
if (__DEV__) {
whyDidYouRender(React, {
trackAllPureComponents: true,
logOnDifferentValues: true,
});
}
// Tag components to track
MovieList.whyDidYouRender = true;
MovieItem.whyDidYouRender = true;
// Console output:
// MovieList re-rendered:
// - props.data: [1,2,3] → [1,2,3] (same reference but different array)
// - props.onRefresh: () => {} → () => {} (new function each render)Flipper (Legacy) / React Native DevTools
# For older React Native versions
npm install -g flipper
# Or use the new React Native DevTools web UI
npx react-native start --devtoolsHermes Profiling
# Hermes is default in Expo SDK 50+
# Profile with Chrome DevTools
# 1. Start app with dev client
npx expo start --dev-client
# 2. Open chrome://inspect in Chrome
# 3. Click "inspect" on your app
# 4. Go to Performance tab → RecordList Performance
FlashList (Recommended)
npx expo install @shopify/flash-listimport { FlashList } from '@shopify/flash-list';
import { View, Text, Image, StyleSheet } from 'react-native';
interface Movie {
id: string;
title: string;
poster: string;
year: number;
}
export function MovieList({ movies }: { movies: Movie[] }) {
return (
<FlashList
data={movies}
renderItem={({ item }) => <MovieItem movie={item} />}
estimatedItemSize={120}
keyExtractor={(item) => item.id}
// Performance props
removeClippedSubviews={true}
maxToRenderPerBatch={10}
windowSize={10}
// Maintain scroll position
maintainVisibleContentPosition={{
minIndexForVisible: 0,
waitFor: 500,
}}
// Custom separators
ItemSeparatorComponent={() => <View style={styles.separator} />}
ListEmptyComponent={<Text style={styles.empty}>No movies</Text>}
ListFooterComponent={<ActivityIndicator />}
/>
);
}
const styles = StyleSheet.create({
separator: { height: 1, backgroundColor: '#e5e7eb' },
empty: { padding: 20, textAlign: 'center', color: '#6b7280' },
});FlatList Optimization
// If using FlatList, optimize heavily
<FlatList
data={movies}
renderItem={({ item }) => <MovieItem movie={item} />}
keyExtractor={(item) => item.id}
// CRITICAL: Provide exact item height
getItemLayout={(data, index) => ({
length: 120,
offset: 120 * index,
index,
})}
// Virtualization
removeClippedSubviews={true}
maxToRenderPerBatch={10}
windowSize={10}
initialNumToRender={10}
// Prevent unnecessary re-renders
ItemSeparatorComponent={() => <View style={styles.separator} />}
// Performance
persistentScrollbar={false}
showsVerticalScrollIndicator={false}
// Disable if not needed
onEndReachedThreshold={0.5}
/>Memoize Item Components
import { memo, useCallback } from 'react';
import { View, Text, Image, Pressable, StyleSheet } from 'react-native';
interface MovieItemProps {
movie: Movie;
onPress: (id: string) => void;
}
// Memoize to prevent re-renders when parent re-renders
const MovieItem = memo(function MovieItem({ movie, onPress }: MovieItemProps) {
return (
<Pressable onPress={() => onPress(movie.id)} style={styles.container}>
<Image source={{ uri: movie.poster }} style={styles.poster} resizeMode="cover" />
<View style={styles.content}>
<Text style={styles.title}>{movie.title}</Text>
<Text style={styles.year}>{movie.year}</Text>
</View>
</Pressable>
);
});
// Parent: memoize callback
function MovieList({ movies }: { movies: Movie[] }) {
const handlePress = useCallback((id: string) => {
router.push(`/movie/${id}`);
}, []);
return (
<FlashList
data={movies}
renderItem={({ item }) => <MovieItem movie={item} onPress={handlePress} />}
estimatedItemSize={120}
keyExtractor={(item) => item.id}
/>
);
}Image Optimization
npx expo install expo-imageimport { Image } from 'expo-image';
<Image
source={movie.poster}
style={styles.poster}
contentFit="cover"
// Performance
transition={200}
cachePolicy="memory-disk"
// Priority loading
priority="high" // For first few items
// Placeholders
placeholder={require('./assets/placeholder.png')}
placeholderContentFit="scale-down"
/>Startup Performance
Measure Startup Time
// App.tsx
import { PerformanceObserver, performance } from 'react-native';
if (__DEV__) {
// Mark app start
performance.mark('app-start');
// Measure time to interactive
const observer = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
if (entry.name === 'app-interactive') {
const duration = entry.startTime;
console.log(`Time to interactive: ${duration.toFixed(2)}ms`);
}
}
});
observer.observe({ entryTypes: ['mark', 'measure'] });
}
// In root component after first render
useEffect(() => {
performance.mark('app-interactive');
performance.measure('startup', 'app-start', 'app-interactive');
}, []);Reduce Bundle Size
# Analyze bundle
npx expo export --platform ios
# Or use metro bundle analyzer
npx @react-native-community/cli bundle --platform ios --dev false --entry-file index.js --bundle-output ios.bundle --assets-dest ./assets
# Analyze with:
npx metro-bundle-analyzer ios.bundleCode Splitting with Dynamic Imports
// Lazy load heavy screens
import { lazy, Suspense } from 'react';
import { View, ActivityIndicator, StyleSheet } from 'react-native';
const HeavyScreen = lazy(() => import('./HeavyScreen').then((m) => ({ default: m.HeavyScreen })));
export function App() {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen
name="Heavy"
component={() => (
<Suspense fallback={<LoadingScreen />}>
<HeavyScreen />
</Suspense>
)}
/>
</Stack.Navigator>
</NavigationContainer>
);
}
function LoadingScreen() {
return <View style={styles.loading}><ActivityIndicator size="large" /></View>;
}Defer Non-Critical Work
import { InteractionManager } from 'react-native';
function App() {
useEffect(() => {
// Run after animations/mount complete
InteractionManager.runAfterInteractions(() => {
// Initialize analytics, crash reporting, etc.
initAnalytics();
initCrashReporting();
prefetchData();
});
}, []);
return <NavigationContainer>...</NavigationContainer>;
}Hermes Bytecode Precompilation
// app.json
{
"expo": {
"jsEngine": "hermes",
"android": {
"jsEngine": "hermes"
}
}
}Hermes compiles JS to bytecode at build time, improving startup ~30%.
Memory Profiling
Xcode Instruments (iOS)
# 1. Build for profiling
eas build --profile production --platform ios --local
# 2. Open in Xcode
open ios/YourApp.xcworkspace
# 3. Product → Profile (Cmd+I)
# 4. Choose "Leaks" or "Allocations"
# 5. Record → Interact → Stop → AnalyzeAndroid Studio Profiler
# 1. Run on device/emulator
npx expo start --dev-client
# 2. Android Studio → View → Tool Windows → Profiler
# 3. Select your app process
# 4. Memory tab → Capture heap dump
# 5. Analyze retained objectsCommon Memory Leaks
| Leak | Cause | Fix |
|---|---|---|
| Event listeners not removed | addEventListener without cleanup | Use useEffect cleanup |
| Timers not cleared | setInterval/setTimeout | Clear in cleanup |
| Large images in memory | Not releasing Image objects | Use expo-image with cache |
| Navigation state | Holding references to unmounted screens | Reset navigation state |
| Closures in state | Capturing large objects in callbacks | Use refs or selectors |
Bundle Size Optimization
Metro Config
// metro.config.js
const { getDefaultConfig } = require('expo/metro-config');
module.exports = (async () => {
const config = await getDefaultConfig(__dirname);
// Enable tree shaking
config.transformer.minifierConfig = {
keep_fnames: true,
mangle: { keep_fnames: true },
};
// Exclude dev-only code
config.resolver.unstable_conditionNames = ['require', 'import', 'default'];
return config;
})();Bundle Analyzer
# Visualize bundle
npx react-native-bundle-visualizer
# Or generate stats
npx expo export --platform ios --output-dir dist
npx bundle-buddy dist/ios/main.jsbundleRemove Unused Dependencies
# Check for unused
npx depcheck
# Remove
npm uninstall unused-packageEAS Build Configuration
eas.json
{
"cli": {
"version": ">= 5.0.0"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal",
"ios": {
"resourceClass": "m-medium",
"simulator": true
},
"android": {
"resourceClass": "medium",
"buildType": "apk"
}
},
"preview": {
"distribution": "internal",
"ios": {
"resourceClass": "m-medium",
"enterpriseProvisioning": "adhoc"
},
"android": {
"resourceClass": "medium",
"buildType": "apk"
}
},
"production": {
"autoIncrement": true,
"ios": {
"resourceClass": "m-medium",
"buildConfiguration": "Release"
},
"android": {
"resourceClass": "medium",
"buildType": "aab"
}
}
},
"submit": {
"production": {
"ios": {
"appleId": "your@email.com",
"ascAppId": "1234567890",
"appleTeamId": "ABCDE12345"
},
"android": {
"serviceAccountKeyPath": "./google-service-account.json",
"track": "production"
}
}
}
}Build Profiles
# Development build (for testing with dev client)
eas build --profile development --platform all
# Preview build (internal testing)
eas build --profile preview --platform all
# Production build (App Store / Play Store)
eas build --profile production --platform all
# Platform specific
eas build --profile production --platform ios
eas build --profile production --platform androidEnvironment Variables
# Set secrets
eas secret:create --scope project --name API_KEY --value "your-api-key"
eas secret:create --scope project --name SENTRY_DSN --value "https://xxx@sentry.io/xxx"
# Use in app.config.js
export default {
expo: {
extra: {
apiKey: process.env.API_KEY,
sentryDsn: process.env.SENTRY_DSN,
},
},
};Build Lifecycle Hooks
// eas.json
{
"build": {
"production": {
"ios": {
"prebuildCommand": "npm run prebuild:ios",
"postbuildCommand": "npm run postbuild:ios"
},
"android": {
"prebuildCommand": "npm run prebuild:android",
"postbuildCommand": "npm run postbuild:android"
}
}
}
}# prebuild:ios
# - Generate native code
# - Run codegen
# - Update dependencies
# postbuild:ios
# - Upload symbols to Sentry
# - Notify teamBuild Artifacts
# List builds
eas build:list --platform ios --limit 10
# View build details
eas build:view <build-id>
# Download artifact
eas build:download --artifact-path ./app.ipa --build-id <build-id>
# Install on device
# iOS: Drag .ipa to Xcode Devices window or use TestFlight
# Android: adb install app.apkEAS Submit
# Submit to App Store
eas submit --platform ios --profile production
# Submit to Play Store
eas submit --platform android --profile production
# With custom track
eas submit --platform android --track betaStore Configuration
// store.config.json
{
"ios": {
"appName": "My App",
"bundleIdentifier": "com.myapp.mobile",
"appleTeamId": "ABCDE12345",
"appStoreUrl": "https://apps.apple.com/app/id123456789",
"sku": "myapp-mobile",
"category": "public.app-category.entertainment",
"privacyPolicyUrl": "https://myapp.com/privacy",
"supportUrl": "https://myapp.com/support"
},
"android": {
"packageName": "com.myapp.mobile",
"versionCode": 1,
"versionName": "1.0.0",
"title": "My App",
"shortDescription": "Best app ever",
"fullDescription": "Long description...",
"icon": "./assets/icon.png",
"featureGraphic": "./assets/feature.png",
"screenshots": {
"phone": ["./screenshots/phone1.png", "./screenshots/phone2.png"],
"tablet": ["./screenshots/tablet1.png"]
}
}
}OTA Updates
# Publish update
eas update --branch production --message "Bug fixes and performance improvements"
# Preview update
eas update --branch preview --message "New feature preview"
# List updates
eas update:list --branch production
# Rollback
eas update:rollback --branch productionUpdate Configuration
// app.json
{
"expo": {
"updates": {
"enabled": true,
"checkAutomatically": "ON_LOAD",
"fallbackToCacheTimeout": 30000,
"url": "https://u.expo.dev/your-project-id"
},
"runtimeVersion": {
"policy": "appVersion"
}
}
}Try It
1. Profile app startup. 2. Profile list scrolling (60fps?). 3. Check bundle size. 4. Build with EAS production. 5. Test on low-end device.
# Profile startup
npx expo start --dev-client
# Chrome → chrome://inspect → Performance
# Check bundle size
npx expo export --platform ios
ls -lh dist/ios/main.jsbundle
# Build production
eas build --profile production --platform allOptimize and ship a React Native app
- Profile MovieList with FlashList vs FlatList
- Memoize all item components
- Optimize images with expo-image
- Reduce bundle size (remove unused deps, code split)
- Configure eas.json for development/preview/production
- Build production AAB/IPA
- Test on low-end device (emulate slow CPU/network)
- Set up OTA updates
- Submit to TestFlight / Play Console Internal
Profile before optimizing. Use FlashList for lists, memoize components, optimize images with expo-image. Hermes bytecode improves startup. EAS builds handle signing, credentials, and store submission. OTA updates for quick fixes without store review. Test on real low-end devices.
Resources
- FlashList Documentation: https://shopify.github.io/flash-list/
- Expo Image: https://docs.expo.dev/versions/latest/sdk/image/
- EAS Build: https://docs.expo.dev/build/introduction/
- EAS Submit: https://docs.expo.dev/submit/introduction/
- EAS Update: https://docs.expo.dev/eas-update/introduction/
- React Native Performance: https://reactnative.dev/docs/performance