Skip to content

React to not unmount the entire tree on uncaught errors #13045

@melloc01

Description

@melloc01

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:

  1. This behavior could be a opt-in or out defined on a component up in the tree, something like a class variable supressErrors = true.
  2. Flag the component that threw the error.
  3. Re-render the whole tree.
  4. 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions