A reusable React Error Boundary
npm install react-component-error-boundaryA lightweight, reusable Error Boundary for React components that follows clean component design principles.
``bash`
npm install react-component-error-boundary
`jsx
import { ErrorBoundary } from "react-component-error-boundary";
`
`jsx
Props API
`ts
interface ErrorBoundaryProps {
children: React.ReactNode;
customErrorMessage?: string;
fallback?: React.ReactNode;
}
``React Error Boundaries often become:
- tightly coupled
- hard to reuse
- mixed with UI logic
This package keeps it simple and flexible:
- Parent owns state
- Child only renders
- Error UI is fully customizable