Skip to content

marcoms/react-safetynet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-safetynet

react-safetynet provides a simple way to encapsulate errors, preventing them from crashing your app completely. Upon receiving an error from one of its children, the component will swap it's contents with an explanation of what went wrong.

Usage

JavaScript

import SafetyNet from 'react-safetynet';

class App extends React.Component {
   render() {
      return (
         <div>
            <h1>SafetyNet Example</h1>

            <SafetyNet>
               {/* The following component throws an error in its render() method */}
               <SuspiciousComponent></SuspiciousComponent>
            </SafetyNet>
         </div>
      );
   }
}

Result

Result

API

The following may be passed as props.

errorHandler

  • Type: (error: Error, errorInfo: React.ErrorInfo) => void

Will be called when an error is caught by the SafetyNet instance. For complete documenation of error and errorInfo, see the React docs.

About

A useful error boundary component for React

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published