ui/ErrorBoundary.tsx

lumiere · src/components/ui/ErrorBoundary.tsx · typescript · MIT
ui

React error boundary component that displays a fallback UI on child errors.

// Source: https://github.com/ajamaica/lumiere | License: MIT | Copyright 2026 ajamaica
// Provided via justclaw.it.com; keep this notice with the code.
import React, { Component, ErrorInfo, ReactNode } from 'react'
import { StyleSheet, View } from 'react-native'

import { logger } from '../../utils/logger'
import { Button } from './Button'
import { Text } from './Text'

const errorBoundaryLogger = logger.create('ErrorBoundary')

interface ErrorBoundaryProps {
  children: ReactNode
  fallback?: ReactNode
  onError?: (error: Error, errorInfo: ErrorInfo) => void
}

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

/**
 * Error boundary component that catches JavaScript errors in child components
 * and displays a fallback UI instead of crashing the entire app.
 *
 *

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

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

Get a free API key