npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-error-shield

v1.0.3

Published

This component is designed to enhance application stability by providing a comprehensive error handling mechanism. It acts as a protective layer around your React components, gracefully capturing errors and displaying user-friendly fallback interfaces or

Downloads

11

Readme

react-error-shield

The react-error-shield is a robust React component designed to enhance application stability by providing a comprehensive error handling mechanism. It acts as a protective layer around your React components, gracefully capturing errors and displaying user-friendly fallback interfaces or messages, without crashing the entire application.

Key Features

  • Versatile Error Handling : Supports various error handling strategies including toast notifications, custom error page, and fallback UI component.

  • Customizable : Offers extensive customization options for error messages, background colors, and more, allowing for a seamless integration with your application's design.

  • Automatic Page Refresh Option : Can refresh the page on error, providing a quick way for users to recover from unexpected issues.

  • Developer Friendly - Simplifies the debugging process by providing clear and concise error information, making it easier to identify and fix issues.


Installation

To install react-error-shield, use npm:

npm install react-error-shield

Usage/Examples

import { ErrorShield } from "react-error-shield";

function App() {
    return (
        <ErrorShield type='TOAST'>
            <App />
        </ErrorShield>
    );
}

Toast

<ErrorShield
    type='TOAST'
    errorBackgroundColor='RED'
    customErrorMsg='Something went wrong! Please try again.'
    refreshPage>
    // ---- child components ---
</ErrorShield>

Error

<ErrorShield
    type='ERROR'
    errorBackgroundColor='RED'
    customErrorMsg='Something went wrong! Please try again.'
    customSecondaryMsg='This is a secondary message.'
    refreshPage>
    // ---- child components ---
</ErrorShield>

Fallback UI

<ErrorShield
    type='FALLBACK'
    fallbackUI={<div>Something went wrong! Please try again.</div>}>
    // ---- child components ---
</ErrorShield>

Props

The following props are expected:

| Props | Required | Value | Default | | -------------------- | :------: | :------------------------------: | :----------------: | | type | true | TOAST or FALLBACK or ERROR | | | errorBackgroundColor | false | RED or YELLOW or GREEN | RED | | customErrorMsg | false | string | Original Error Msg | | customSecondaryMsg | false | string | Original Error Msg | | refreshPage | false | boolean | | | fallbackUI | false | React Component | |

If the type is FALLBACK, the fallbackUI prop is expected. If not passed, it will default to the ERROR behavior.

The customSecondaryMsg prop only works with the type set to ERROR.