onComponentDidCatch property

  1. @override
dynamic Function(dynamic error, ReactErrorInfo info)? get onComponentDidCatch
override

An optional callback that will be called with an Error (or Exception) and errorInfo containing information about which component in the tree threw when the componentDidCatch lifecycle method is called.

This callback can be used to log component errors like so:

(ErrorBoundary()
  ..onComponentDidCatch = (error, errorInfo) {
    // It is up to you to implement the service / thing that calls the service.
    logComponentStackToAService(error, errorInfo);
  }
)(
  // The rest of your component tree
)

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

Related: onComponentIsUnrecoverable

Implementation

@override
Function(dynamic error, ReactErrorInfo info)? get onComponentDidCatch =>
    (props[_$key__onComponentDidCatch__ErrorBoundaryProps] ?? null)
        as Function(dynamic error, ReactErrorInfo info)?;
  1. @override
set onComponentDidCatch (dynamic value(dynamic error, ReactErrorInfo info)?)
override

An optional callback that will be called with an Error (or Exception) and errorInfo containing information about which component in the tree threw when the componentDidCatch lifecycle method is called.

This callback can be used to log component errors like so:

(ErrorBoundary()
  ..onComponentDidCatch = (error, errorInfo) {
    // It is up to you to implement the service / thing that calls the service.
    logComponentStackToAService(error, errorInfo);
  }
)(
  // The rest of your component tree
)

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

Related: onComponentIsUnrecoverable

Implementation

@override
set onComponentDidCatch(
        Function(dynamic error, ReactErrorInfo info)? value) =>
    props[_$key__onComponentDidCatch__ErrorBoundaryProps] = value;