componentDidCatch method

  1. @override
void componentDidCatch(
  1. dynamic error,
  2. ReactErrorInfo info
)
override

ReactJS lifecycle method that is invoked after an error is thrown by a descendant.

Use this method primarily for logging errors, but because it takes place after the commit phase side-effects are permitted.

Note: This method, along with getDerivedStateFromError will only be called if skipMethods in registerComponent2 is overridden with a list that includes the names of these methods. Otherwise, in order to prevent every component from being an "error boundary", componentDidCatch and getDerivedStateFromError will be ignored.

See: reactjs.org/docs/react-component.html#componentdidcatch

Implementation

@override
void componentDidCatch(error, ReactErrorInfo info) {
  props.onComponentDidCatch?.call(error, info);
  _logErrorCaughtByErrorBoundary(error, info);
  props.onComponentIsUnrecoverable?.call(error, info);
}