-
Notifications
You must be signed in to change notification settings - Fork 50.5k
Description
Do you want to request a feature or report a bug?
Feature request
What is the current behavior?
Whole app unmounts on uncaught errors.
What is the expected behavior?
It'd be good to just unmount the affected tree.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React@16
Hi guys, I feel like the "new" error handling approach on React 16 is too harsh for our App. We have plenty of plugin "entrypoints" for external React components that we consider error prone. While having an ErrorBoundary for each is a solution, I'd prefer that only the affected component tree to be unmounted in case some of these components, or even internal components spits an error.
A way to achieve this with the new error handling system would be to:
- This behavior could be a opt-in or out defined on a component up in the tree, something like a class variable
supressErrors = true. - Flag the component that threw the error.
- Re-render the whole tree.
- Do not render flagged components.
The effect would be like a default ErrorBoundary wrapping every component down the tree where the boundary just spits null instead of crashing the whole app.
What do you think?