react-error-boundary-lib

1.0.4 • Public • Published

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;

Readme

Keywords

none

Package Sidebar

Install

npm i react-error-boundary-lib

Weekly Downloads

5

Version

1.0.4

License

ISC

Unpacked Size

7.05 kB

Total Files

6

Last publish

Collaborators

  • harshitsr007