Developer Menu
The Developer Menu provides quick access to debugging tools and can be accessed by:- iOS Simulator: Cmd + D
- Android Emulator: Cmd/Ctrl + M
- Physical Device: Shake gesture
Available Options
The Developer Menu includes:- Reload: Reload the JavaScript bundle
- Debug with Chrome: Opens Chrome DevTools for debugging
- Toggle Inspector: Inspect element hierarchies and styles
- Show Performance Monitor: Display memory and performance metrics
- Fast Refresh: Enable/disable automatic refresh on file changes
LogBox
LogBox is React Native’s built-in error and warning management system. It provides a better developer experience by:- Displaying errors with syntax highlighting and stack traces
- Collapsing framework-internal logs for clarity
- Providing actionable error messages
- Allowing log filtering and dismissal
Using LogBox
React DevTools
React DevTools allows you to inspect the React component hierarchy, props, and state.Installation
Usage
Chrome DevTools
When using the “Debug with Chrome” option, you can access:- Console: View console.log output and errors
- Sources: Set breakpoints and step through code
- Network: Inspect network requests (limited in React Native)
- Performance: Profile JavaScript execution
Debugging JavaScript
Native Debugging
iOS
Use Xcode to debug native iOS code:- Open
ios/YourApp.xcworkspacein Xcode - Set breakpoints in Objective-C or Swift files
- Run the app from Xcode (Cmd + R)
- Use the debugger when breakpoints are hit
Android
Use Android Studio to debug native Android code:- Open the
androidfolder in Android Studio - Set breakpoints in Java or Kotlin files
- Run the app in debug mode
- Attach the debugger to the process
Performance Monitoring
DevSettings Module
Customize developer settings programmatically:Network Debugging
Using Flipper
Flipper provides network inspection capabilities:- Install Flipper desktop app
- Enable the Network plugin
- View all network requests with headers, bodies, and timing
Manual Network Logging
Source Maps
React Native automatically generates source maps for debugging. The Metro bundler includes source map support that allows you to:- See original file names and line numbers in stack traces
- Set breakpoints in your original source code
- Step through code that matches your source files
Symbolicating Stack Traces
For production crashes, symbolicate stack traces:Common Debugging Scenarios
Red Screen Errors
Red screens indicate fatal errors:- Read the error message carefully
- Check the stack trace for the error source
- Look for file names and line numbers
- Click on stack frames to open in editor
Yellow Box Warnings
Address warnings by:- Updating deprecated APIs
- Fixing incorrect prop types
- Resolving performance issues
Remote Debugging Caveats
- Performance is slower when remote debugging
- Some native modules may behave differently
- Async operations may have different timing
Best Practices
- Use TypeScript: Catch errors at compile time
- Enable Fast Refresh: See changes instantly
- Use console methods wisely: Leverage console.group, console.table
- Set up error boundaries: Catch React errors gracefully
- Test on real devices: Simulators don’t catch all issues
- Use Flipper: Comprehensive debugging for both platforms
- Keep DevTools open: Monitor logs and network in real-time
Next Steps
Metro Bundler
Configure Metro for optimal development
Testing
Set up testing for your application