ErrorBoundary
Class Components
ErrorBoundary
An ErrorBoundary serves the purpose of catching and displaying errors when a component fails to load.
Param
the component that needs to load
Param
(optional) fallback component when error occurs
Param
(optional) object containing the error message and type
Param
(optional) log to the console if provided
Example
<ErrorBoundary>
errorObj={{
type: 'script-error',
title: t('Error in loading reflection.'),
}}
>
<SomeChildComponent />
</ErrorBoundary>
Extends
Component
<ErrorBoundaryProps
,ErrorBoundaryState
>
Constructors
new ErrorBoundary()
new ErrorBoundary(
props
):ErrorBoundary
Parameters
Parameter | Type |
---|---|
props | ErrorBoundaryProps |
Returns
Overrides
React.Component<ErrorBoundaryProps, ErrorBoundaryState>.constructor
Source
libs/design-system-core/src/components/ErrorBoundary/index.tsx:34
Methods
componentDidCatch()
componentDidCatch(
error
):void
Parameters
Parameter | Type |
---|---|
error | Error |
Returns
void
Overrides
React.Component.componentDidCatch
Source
libs/design-system-core/src/components/ErrorBoundary/index.tsx:39
render()
render():
Element
Returns
Element
Overrides
React.Component.render
Source
libs/design-system-core/src/components/ErrorBoundary/index.tsx:44
Components
withErrorBoundary()
withErrorBoundary<
T
>(WrappedComponent
): (props
) =>Element
Type parameters
Type parameter |
---|
T extends ErrorBoundaryProps |
Parameters
Parameter | Type |
---|---|
WrappedComponent | ComponentType <T > |
Returns
Function
Parameters
Parameter | Type |
---|---|
props | T |
Returns
Element
Source
libs/design-system-core/src/components/ErrorBoundary/index.tsx:60
Props
ErrorBoundaryProps
ErrorBoundaryProps:
object
Type declaration
Member | Type |
---|---|
children | React.ReactElement |
errorObj | Pick <ErrorLoaderProps , "type" | "title" > |
fallback | React.ReactElement |
logger | ILogger |
Source
libs/design-system-core/src/components/ErrorBoundary/index.tsx:5
ErrorBoundaryState
ErrorBoundaryState:
object
Type declaration
Member | Type |
---|---|
error | Error |
hasError | boolean |
Source
libs/design-system-core/src/components/ErrorBoundary/index.tsx:12