Open History to see the last commit
1import { useErrorBoundary } from 'preact/hooks'
2import type { ComponentChildren } from 'preact'
3β
4export default function ErrorBoundary({
5 children,
6 fallback,
7}: {
8 children: ComponentChildren
9 fallback: (error: Error) => ComponentChildren
10}) {
11 const [error] = useErrorBoundary()
12β
13 return error ? fallback(error) : children
14}