Development vs Production Error Display
What you'll learn: How React's error overlay behavior changes between development and production modes, and why that matters for debugging and user experience.
Two Faces of Error Boundaries
When an error boundary catches an error, React treats it differently depending on whether you're running npm start (development) or a built production bundle (npm run build). This isn't about your error boundary component—it's about React's built-in error overlay.
Development Mode: The Red Screen
In development, when an error is caught, React shows a big red error overlay covering your entire app. This overlay displays:
- The full error stack trace
- The component tree where the error occurred
- Source code snippets with line numbers
- A clickable path to the exact file
This is intentionally aggressive—React wants you to fix bugs immediately. Even though your error boundary may render a fallback UI, the overlay appears on top of it.
You can dismiss the overlay by clicking the X, which then reveals your error boundary's fallback UI underneath.
Production Mode: Silent Fallback
In production builds, React removes all this developer-facing machinery. When an error is caught:
- No red overlay appears
- Only your error boundary's fallback UI is shown
- Error details are not displayed to users
componentDidCatchstill fires for logging
This protects your users from seeing scary technical details and potential security information (like file paths or internal variable names).
Why This Matters
You need to test your error boundary UI in production mode to see what users will actually experience. What looks acceptable under a dismissible overlay might feel jarring as the sole interface when something breaks.
Key Takeaway: React shows detailed error overlays in development but defers completely to your error boundary's fallback in production—always test the production experience.