From 562057f8bacf1d86eab554fe0c436b189feb5d97 Mon Sep 17 00:00:00 2001 From: Vadim Brodsky Date: Tue, 25 Jun 2019 10:46:14 -0400 Subject: [PATCH] Update docs re dev vs prod The fact that error boundaries behave differently depending on the environment is surprising, this adds more information about the differences. Reference: https://github.com/facebook/react/issues/12897#issuecomment-410036991 --- content/docs/error-boundaries.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/content/docs/error-boundaries.md b/content/docs/error-boundaries.md index 1477329112e..7a2a92c4c2b 100644 --- a/content/docs/error-boundaries.md +++ b/content/docs/error-boundaries.md @@ -74,6 +74,13 @@ Check out [this example of declaring and using an error boundary](https://codepe The granularity of error boundaries is up to you. You may wrap top-level route components to display a “Something went wrong” message to the user, just like server-side frameworks often handle crashes. You may also wrap individual widgets in an error boundary to protect them from crashing the rest of the application. +## Difference in Behavior Between Development and Production {#difference-in-behavior-between-development-and-production} + +In development environment exceptions are thrown inside a fake DOM event which makes them reported by `window.onerror`, but then React actually catches them so that they don't propagate up. + +In production environment errors caught by error boundaries stay caught. + + ## New Behavior for Uncaught Errors {#new-behavior-for-uncaught-errors} This change has an important implication. **As of React 16, errors that were not caught by any error boundary will result in unmounting of the whole React component tree.**