onComponentIsUnrecoverable property

dynamic Function(dynamic error, ReactErrorInfo info)? onComponentIsUnrecoverable
getter/setter pair

An optional callback that will be called (when fallbackUIRenderer is not set) with an Error (or Exception) and errorInfo containing information about which component in the tree threw multiple consecutive errors/exceptions frequently enough that it has the potential to lock the main thread.

The locking of the main thread is possible in this scenario because when fallbackUIRenderer is not set, the ErrorBoundary simply re-mounts the child when an error occurs to try to "recover" automatically. However, if multiple identical errors are thrown from the exact same component in the tree - every time the ErrorBoundary re-mounts the tree, a sort of "infinite loop" will occur.

When this callback is called, the tree wrapped by this ErrorBoundary has "crashed" - and is completely non-functional. Instead of re-mounting the component tree, the ErrorBoundary will simply render a static copy of the render tree's HTML that was captured at the time of the error.

Once this happens, regaining interactivity within the tree wrapped by this ErrorBoundary is possible by:

  1. Passing in a new child (preferably one that will not repeatedly throw errors when the ErrorBoundary mounts it).
  2. Calling ErrorBoundaryComponent.reset.

Will never be called when fallbackUIRenderer is set.

Related: identicalErrorFrequencyTolerance

Implementation

Function(/*Error||Exception*/dynamic error, ReactErrorInfo info)? onComponentIsUnrecoverable;