ErrorBoundary (primitives/error-boundary.tsx)

editor · packages/editor/src/components/ui/primitives/error-boundary.tsx · typescript · MIT
ui

React error boundary that displays a fallback UI and logs errors.

// Source: https://github.com/pascalorg/editor | License: MIT | Copyright 2026 Pascal Group Inc
// Provided via justclaw.it.com; keep this notice with the code.
'use client'

import React, { Component, type ErrorInfo, type ReactNode } from 'react'

interface Props {
  children?: ReactNode
  fallback?: ReactNode
}

interface State {
  hasError: boolean
  error: Error | null
}

export class ErrorBoundary extends Component<Props, State> {
  public state: State = {
    hasError: false,
    error: null,
  }

  public static getDerivedStateFromError(error: Error): State {
    return { hasError: true, error }
  }

  public componentDidCatch(error: Error, errorInfo: ErrorInfo) {
    console.error('Uncaught error:', error, errorInfo)
  }

  public render() {
    if (this.state.hasError) {
      if 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key