Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

ErrorBoundary.tsx

14 lines333 Bytes

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