Home / Class/ ComponentErrorBoundary Class — ui Architecture

ComponentErrorBoundary Class — ui Architecture

Architecture documentation for the ComponentErrorBoundary class in component-wrapper.tsx from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  29f61fbc_5a29_79ef_be4b_a760b0af561c["ComponentErrorBoundary"]
  e45a2200_2ccc_c5a6_144d_516890bb99cb["component-wrapper.tsx"]
  29f61fbc_5a29_79ef_be4b_a760b0af561c -->|defined in| e45a2200_2ccc_c5a6_144d_516890bb99cb
  87c8068d_e0f0_5464_cf04_963f55d92ba3["constructor()"]
  29f61fbc_5a29_79ef_be4b_a760b0af561c -->|method| 87c8068d_e0f0_5464_cf04_963f55d92ba3
  400c34f6_a4db_8b65_f537_ef15106f4a2f["getDerivedStateFromError()"]
  29f61fbc_5a29_79ef_be4b_a760b0af561c -->|method| 400c34f6_a4db_8b65_f537_ef15106f4a2f
  387e4368_ff1f_01bc_2a1e_20dda26cc180["componentDidCatch()"]
  29f61fbc_5a29_79ef_be4b_a760b0af561c -->|method| 387e4368_ff1f_01bc_2a1e_20dda26cc180
  ebe21df3_8097_ef36_e966_386dfdd9a1c0["render()"]
  29f61fbc_5a29_79ef_be4b_a760b0af561c -->|method| ebe21df3_8097_ef36_e966_386dfdd9a1c0

Relationship Graph

Source Code

apps/v4/components/component-wrapper.tsx lines 33–61

class ComponentErrorBoundary extends React.Component<
  { children: React.ReactNode; name: string },
  { hasError: boolean }
> {
  constructor(props: { children: React.ReactNode; name: string }) {
    super(props)
    this.state = { hasError: false }
  }

  static getDerivedStateFromError() {
    return { hasError: true }
  }

  componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
    console.error(`Error in component ${this.props.name}:`, error, errorInfo)
  }

  render() {
    if (this.state.hasError) {
      return (
        <div className="p-4 text-red-500">
          Something went wrong in component: {this.props.name}
        </div>
      )
    }

    return this.props.children
  }
}

Frequently Asked Questions

What is the ComponentErrorBoundary class?
ComponentErrorBoundary is a class in the ui codebase, defined in apps/v4/components/component-wrapper.tsx.
Where is ComponentErrorBoundary defined?
ComponentErrorBoundary is defined in apps/v4/components/component-wrapper.tsx at line 33.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free