react-error-boundary-lib
v1.0.4
Published
A robust error boundary component for React applications, providing graceful error handling and recovery across all React versions.
Downloads
24
Readme
react-error-boundary-lib
A lightweight React Error Boundary component that catches JavaScript errors in child components, logs those errors, and displays a fallback UI.
Installation
To install the package, run:
npm install react-error-boundary-lib
import React from 'react';
import ErrorBoundary from 'react-error-boundary-lib';
import Root from './Root'; // Your main component
// Define a redirect function
const redirectToHomePage = () => {
window.location.href = '/';
};
function App() {
return (
<ErrorBoundary location={redirectToHomePage}>
<Root />
</ErrorBoundary>
);
}
export default App;