Skip to main content
This guide covers common issues you might encounter when developing React Native applications and their solutions.

Build Errors

Symptoms:
error: Error: Unable to resolve module `./MyComponent`
Module does not exist in the Haste module map
Solutions:
  1. Clear Metro cache:
    npx react-native start --reset-cache
    
  2. Check import path:
    // ❌ Wrong
    import MyComponent from './myComponent'; // Case mismatch
    
    // ✅ Correct
    import MyComponent from './MyComponent';
    
  3. Clear node_modules and reinstall:
    rm -rf node_modules
    npm install
    
  4. Check file extension:
    // If file is MyComponent.tsx
    import MyComponent from './MyComponent'; // .tsx not needed
    
  5. Watchman issues:
    watchman watch-del-all
    
Symptoms:
[!] CocoaPods could not find compatible versions for pod
Unable to install required dependencies
Solutions:
  1. Update CocoaPods:
    sudo gem install cocoapods
    
  2. Deintegrate and reinstall:
    cd ios
    pod deintegrate
    pod install
    cd ..
    
  3. Update pod repo:
    pod repo update
    pod install --repo-update
    
  4. Clear CocoaPods cache:
    rm -rf ~/Library/Caches/CocoaPods
    rm -rf Pods
    rm Podfile.lock
    pod install
    
  5. Check Podfile platform version:
    # ios/Podfile
    platform :ios, '13.4' # Must meet minimum requirement
    
Symptoms:
FAILURE: Build failed with an exception
Could not resolve all dependencies
Solutions:
  1. Clean Gradle:
    cd android
    ./gradlew clean
    cd ..
    
  2. Clear Gradle cache:
    cd android
    ./gradlew cleanBuildCache
    rm -rf ~/.gradle/caches/
    cd ..
    
  3. Update Gradle version:
    # android/gradle/wrapper/gradle-wrapper.properties
    distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
    
  4. Check Android SDK:
    • Open Android Studio
    • SDK Manager → Install required SDK versions
    • Set ANDROID_HOME environment variable
  5. Sync project with Gradle files in Android Studio
Symptoms:
'React/RCTBridgeModule.h' file not found
'React/RCTEventEmitter.h' file not found
Solutions:
  1. Clean and reinstall:
    cd ios
    rm -rf Pods Podfile.lock
    pod install
    cd ..
    
  2. Clear Xcode derived data:
    rm -rf ~/Library/Developer/Xcode/DerivedData/*
    
  3. Clean build folder in Xcode:
    • Product → Clean Build Folder (Cmd + Shift + K)
  4. Check Header Search Paths in Xcode:
    • Build Settings → Header Search Paths
    • Should include $(SRCROOT)/../node_modules/react-native/React

Runtime Errors

Symptoms:
Invariant Violation: Element type is invalid
Invariant Violation: View config getter callback must be a function
Solutions:
  1. Check component imports:
    // ❌ Wrong
    import Button from 'react-native';
    
    // ✅ Correct
    import {Button} from 'react-native';
    
  2. Verify component exports:
    // Component.js
    export default function MyComponent() { /* ... */ }
    
    // Usage
    import MyComponent from './Component';
    
  3. Check for circular dependencies
  4. Ensure component is properly defined:
    // ❌ Wrong
    const MyComponent = () => {
      return (
        <View>
        // Missing closing tag
      );
    };
    
    // ✅ Correct
    const MyComponent = () => {
      return (
        <View>
          <Text>Hello</Text>
        </View>
      );
    };
    
Symptoms:
Network request failed
TypeError: Network request failed
Solutions:
  1. Check network connectivity
  2. Allow HTTP on iOS (development only):
    <!-- ios/MyApp/Info.plist -->
    <key>NSAppTransportSecurity</key>
    <dict>
      <key>NSAllowsArbitraryLoads</key>
      <true/>
    </dict>
    
  3. Check Android network permissions:
    <!-- android/app/src/main/AndroidManifest.xml -->
    <uses-permission android:name="android.permission.INTERNET" />
    
  4. Use correct localhost address:
    • iOS Simulator: http://localhost:3000
    • Android Emulator: http://10.0.2.2:3000
    • Physical device: Use computer’s IP address
  5. Check CORS on backend
  6. Verify API endpoint:
    // Test with curl first
    // curl https://api.example.com/endpoint
    
Symptoms:
  • App shows white/blank screen
  • No errors in console
Solutions:
  1. Check Metro bundler is running:
    npx react-native start
    
  2. Reload JavaScript:
    • iOS: Cmd + R
    • Android: Press R twice or Cmd/Ctrl + M → Reload
  3. Check App.js/index.js:
    // index.js
    import {AppRegistry} from 'react-native';
    import App from './App';
    import {name as appName} from './app.json';
    
    AppRegistry.registerComponent(appName, () => App);
    
  4. Check for JavaScript errors:
    • Open React Native Debugger
    • Check console for errors
  5. Verify root component renders:
    // App.js
    import React from 'react';
    import {SafeAreaView, Text} from 'react-native';
    
    function App() {
      return (
        <SafeAreaView>
          <Text>Hello World</Text>
        </SafeAreaView>
      );
    }
    
    export default App;
    
Symptoms:
  • App crashes immediately
  • No JavaScript error
Solutions:
  1. Check native logs: iOS:
    # View device logs
    xcrun simctl spawn booted log stream --level=debug
    
    Android:
    adb logcat
    
  2. Clean and rebuild:
    # iOS
    cd ios
    rm -rf build
    xcodebuild clean
    cd ..
    npx react-native run-ios
    
    # Android
    cd android
    ./gradlew clean
    cd ..
    npx react-native run-android
    
  3. Check native module compatibility:
    • Verify all native modules support your React Native version
    • Update or remove incompatible modules
  4. Reinstall native dependencies:
    rm -rf node_modules
    npm install
    cd ios && pod install && cd ..
    

Performance Issues

Symptoms:
  • Slow screen transitions
  • Laggy animations
  • Dropped frames
Solutions:
  1. Enable Hermes: iOS (ios/Podfile):
    :hermes_enabled => true
    
    Android (android/app/build.gradle):
    project.ext.react = [
      enableHermes: true
    ]
    
  2. Use React.memo for expensive components:
    const MyComponent = React.memo(({data}) => {
      return <View>{/* ... */}</View>;
    });
    
  3. Optimize FlatList:
    <FlatList
      data={data}
      renderItem={renderItem}
      keyExtractor={item => item.id}
      removeClippedSubviews={true}
      maxToRenderPerBatch={10}
      updateCellsBatchingPeriod={50}
      initialNumToRender={10}
      windowSize={10}
    />
    
  4. Use InteractionManager:
    InteractionManager.runAfterInteractions(() => {
      // Expensive operation after navigation completes
      this.setState({dataLoaded: true});
    });
    
  5. Profile with React DevTools Profiler
Symptoms:
  • App crashes with out of memory
  • Slow performance over time
Solutions:
  1. Optimize images:
    // Use appropriate image sizes
    <Image
      source={{uri: imageUrl}}
      style={{width: 100, height: 100}}
      resizeMode="cover"
    />
    
    // Use react-native-fast-image for better caching
    import FastImage from 'react-native-fast-image';
    
    <FastImage
      source={{uri: imageUrl}}
      style={{width: 100, height: 100}}
      resizeMode={FastImage.resizeMode.cover}
    />
    
  2. Clean up listeners and timers:
    useEffect(() => {
      const subscription = eventEmitter.addListener('event', handler);
      
      return () => {
        subscription.remove();
      };
    }, []);
    
  3. Limit list rendering:
    • Use FlatList instead of ScrollView for long lists
    • Implement virtualization
    • Remove items outside viewport
  4. Monitor with Performance Monitor:
    • Shake device → Show Performance Monitor
    • Watch Memory usage

Metro Bundler Issues

Symptoms:
Loading dependency graph...
(stuck indefinitely)
Solutions:
  1. Reset cache:
    npx react-native start --reset-cache
    
  2. Clear watchman:
    watchman watch-del-all
    
  3. Clear Metro cache:
    rm -rf $TMPDIR/metro-*
    rm -rf $TMPDIR/haste-map-*
    
  4. Increase Node memory:
    NODE_OPTIONS=--max_old_space_size=4096 npx react-native start
    
  5. Check for circular dependencies
Symptoms:
ERROR  EADDRINUSE: address already in use :::8081
Solutions:
  1. Kill process on port 8081: macOS/Linux:
    lsof -ti:8081 | xargs kill -9
    
    Windows:
    netstat -ano | findstr :8081
    taskkill /PID <PID> /F
    
  2. Use different port:
    npx react-native start --port 8088
    
    Then run app with custom port:
    RCT_METRO_PORT=8088 npx react-native run-ios
    

Debugging Tools

Solutions:
  1. Ensure React DevTools is running:
    npx react-devtools
    
  2. Reload app after opening DevTools
  3. Check firewall settings
  4. Try different port:
    npx react-devtools --port 8098
    
Solutions:
  1. Use Hermes debugger instead:
    • Shake device → “Debug with Chrome” becomes “Hermes Debugger”
  2. Disable Chrome extensions
  3. Clear Chrome cache
  4. Use Flipper instead:
    npx react-native-community/cli doctor
    # Install Flipper if suggested
    

Environment Issues

Solutions:
  1. Use npx:
    npx react-native <command>
    
  2. Install globally (not recommended):
    npm install -g react-native-cli
    
  3. Add to PATH:
    export PATH="$PATH:./node_modules/.bin"
    
Solutions:
  1. Check Node version:
    node --version  # Should be v18+ or v22+ for RN 0.84+
    
  2. Update Node using nvm:
    nvm install 22
    nvm use 22
    nvm alias default 22
    
  3. Clear npm cache:
    npm cache clean --force
    

Testing Issues

Solutions:
  1. Configure Jest transform:
    // jest.config.js
    module.exports = {
      preset: 'react-native',
      transformIgnorePatterns: [
        'node_modules/(?!(@react-native|react-native|react-native-.*)/)',
      ],
    };
    
  2. Mock native modules:
    // __mocks__/react-native.js
    const ReactNative = require('react-native');
    
    ReactNative.NativeModules = {
      ...ReactNative.NativeModules,
      // Mock your native modules
    };
    
    module.exports = ReactNative;
    
  3. Clear Jest cache:
    jest --clearCache
    

Getting Help

When seeking help:
  1. Provide error logs:
    • Full error message
    • Stack trace
    • Metro bundler output
  2. Share environment info:
    npx react-native info
    
  3. Create minimal reproduction:
    • Isolate the issue
    • Share code that reproduces the problem
  4. Check existing issues:

Next Steps

Debugging

Learn debugging techniques

Upgrading

Upgrade React Native safely

Build docs developers (and LLMs) love