errorFallback
It provides a fallback for components that throw errors.
Installation
npm install react-beyond @react-beyond/errorfallback
Usage
import { Beyond } from 'react-beyond'
import { errorFallback } from '@react-beyond/errorFallback'
<Beyond features={[errorFallback(<options>)]}>
<App x-error-fallback={true} />
</Beyond>
Options
id
- The id of the feature HOC. Defaults to errorFallback.forAll?
- Whether to apply error handling to all components or only to those that have the x-error-fallback prop. Defaults totrue
.mode?: 'trycatch' | 'errorboundary'
: The mode of error handling.- trycatch: uses a try/catch block when rendering the component.
- errorboundary: wraps the component in an ErrorBoundary.
defaultFallback?: ReactElement | ((componentName: string) => ReactElement)
- The fallback to use when no fallback is provided for a component. Defaults to a component showing the text "[ComponentName error]".
Directive
x-error-fallback?: | true | ReactElement | ((componentName: string) => ReactElement)
- The fallback to render when an error occurs, ortrue
to use the default fallback.