Skip to content

components/ErrorBoundary

import { … } from 'zidane-ui'ui/src/components/ErrorBoundary.tsx

Components#

ErrorDetailsComponent#

The error message; with stacks on (configureErrorReports) the JS and component stacks under a disclosure.

TypeScript
function ErrorDetails(props: ErrorDetailsProps): Element
Parameters
NameTypeDescription
propsErrorDetailsProps

The error and its component stack.

Element
ErrorDetails props
NameTypeDescription
componentStackstring | null

React's component stack, once known.

errorunknown

What was thrown.

ui/src/components/ErrorBoundary.tsx:187

ErrorFallbackComponent#

The default fallback: what failed, why, and a way back.

TypeScript
function ErrorFallback(props: ErrorFallbackFrameProps): Element
Parameters
NameTypeDescription
propsErrorFallbackFrameProps

The error, the region and the reset.

Element
ErrorFallback props
NameTypeDescription
actions?ReactNode

Extra buttons next to "Try again".

className?string

The container's classes.

componentStackfrom ErrorFallbackPropsstring | null

React's component stack, once known.

errorfrom ErrorFallbackPropsunknown

What was thrown.

framed?boolean

Drawn as a tray (default true).

regionstring

Names the region ("Sidebar").

resetfrom ErrorFallbackProps() => void

Clears the error and renders the region again.

ui/src/components/ErrorBoundary.tsx:139

Classes#

ErrorBoundaryClass#

Catches a throw in its children and shows a fallback in their place (see the top of this file).

TypeScript
class ErrorBoundary extends Component<ErrorBoundaryProps, State>
TypeScript
new ErrorBoundary(props: ErrorBoundaryProps)
Parameters
NameTypeDescription
propsErrorBoundaryProps

The region's name, its children and the fallback.

ErrorBoundary properties
NameTypeDescription
stateState

Whether it caught, what, and the resetKey it caught under.

componentDidCatch()

TypeScript
componentDidCatch(error: unknown, info: ErrorInfo): void

React's hook: logs the caught error once, with the region.

Parameters
NameTypeDescription
errorunknown

What was thrown.

infoErrorInfo

React's component stack.

render()

TypeScript
render(): ReactNode

The children, or the fallback after a throw.

ReactNode

reset()

TypeScript
reset(): void

Clears the error and renders the region again.

ErrorBoundary.getDerivedStateFromError()

TypeScript
ErrorBoundary.getDerivedStateFromError(error: unknown): Partial<State>

React's hook: a child threw.

Parameters
NameTypeDescription
errorunknown

What was thrown.

Partial<State>

ErrorBoundary.getDerivedStateFromProps()

TypeScript
ErrorBoundary.getDerivedStateFromProps(
  props: ErrorBoundaryProps,
  state: State,
): Partial<State> | null

React's hook: a new resetKey clears a caught error.

Parameters
NameTypeDescription
propsErrorBoundaryProps

The new props.

stateState

The state now.

Partial<State> | null

ui/src/components/ErrorBoundary.tsx:60

Interfaces#

ErrorBoundaryPropsInterface#

Props for ErrorBoundary.

TypeScript
interface ErrorBoundaryProps
ErrorBoundaryProps properties
NameTypeDescription
actions?ReactNode

Extra buttons next to "Try again" in the default fallback (the root's "Reload window").

childrenReactNode

The region.

className?string

The default fallback's container classes: it takes the region's place in the layout.

fallback?((props: ErrorFallbackProps) => ReactNode) | null

Replaces the default fallback. null renders nothing: a host with no surface of its own (attention watchers, request bridges).

framed?boolean

Default fallback drawn as a tray; off on a surface that already is one.

regionstring

Names the region in the log and in the fallback ("Sidebar", "Side panel").

resetKey?unknown

Clears a caught error when it changes (compared with Object.is).

ui/src/components/ErrorBoundary.tsx:32

ErrorDetailsPropsInterface#

Props for ErrorDetails.

TypeScript
interface ErrorDetailsProps
ErrorDetailsProps properties
NameTypeDescription
componentStackstring | null

React's component stack, once known.

errorunknown

What was thrown.

ui/src/components/ErrorBoundary.tsx:175

ErrorFallbackFramePropsInterface#

Props for ErrorFallback.

TypeScript
interface ErrorFallbackFrameProps extends ErrorFallbackProps
ErrorFallbackFrameProps properties
NameTypeDescription
actions?ReactNode

Extra buttons next to "Try again".

className?string

The container's classes.

componentStackfrom ErrorFallbackPropsstring | null

React's component stack, once known.

errorfrom ErrorFallbackPropsunknown

What was thrown.

framed?boolean

Drawn as a tray (default true).

regionstring

Names the region ("Sidebar").

resetfrom ErrorFallbackProps() => void

Clears the error and renders the region again.

ui/src/components/ErrorBoundary.tsx:123

ErrorFallbackPropsInterface#

What a fallback receives.

TypeScript
interface ErrorFallbackProps
ErrorFallbackProps properties
NameTypeDescription
componentStackstring | null

React's component stack, once known.

errorunknown

What was thrown.

reset() => void

Clears the error and renders the region again.

ui/src/components/ErrorBoundary.tsx:22