Socket
Socket
Sign inDemoInstall

@vlsergey/react-bootstrap-error-boundary

Package Overview
Dependencies
31
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @vlsergey/react-bootstrap-error-boundary

Ready-to-use error boundary with Bootstrap Alert as error text display


Version published
Weekly downloads
5
decreased by-82.76%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

@vlsergey/react-bootstrap-error-boundary

Ready-to-use error boundary with Bootstrap Alert as error text display.

NPM version Build Status Downloads

Goal

Do not duplicate same code of for Alert usage in different projects.

Installation

npm i --save @vlsergey/react-bootstrap-error-boundary

or

npm i --save-dev @vlsergey/react-bootstrap-error-boundary

Usage

import ErrorBoundary from '@vlsergey/react-bootstrap-error-boundary';

/*...*/

<ErrorBoundary>
    {/*...*/}
</ErrorBoundary>

Example with "retry" button

import Button from 'react-bootstrap/Button';
import ErrorBoundary from '@vlsergey/react-bootstrap-error-boundary';

class MyComponent extends PureComponent {
  state = {
    retryCounter : 0,
  }

  handleRetry = () =>
    this.setState( ({retryCounter}) => ({retryCounter : retryCounter+1}) );

  render() {
    return <>
      {/*...*/}
      <ErrorBoundary
        errorMessageSuffix={<><br /><Button onClick={this.handleRetry}>retry</Button><>}
        key={`ErrorBoundary_${this.state.retryCounter}`}>
          {/*...*/}
      </ErrorBoundary>
      {/*...*/}
    </>;
  }
}

Props

PropertyTypeDefault valueDescription
logToConsolebooleantrueLog error and react error info to browser console
errorMessage( error : unknown ) : ReactNode(prefix)(error)Text (react node) to display on error as Alert children. Defined as function of error.
errorMessagePrefixreact node (may be string)"Error occured: "Prefix to display before error message. Ignored if errorMessage function is provided.
errorMessageSuffixreact node (may be string)""Suffix to display after error message. Ignored if errorMessage function is provided.
variantSee bootstrap Alert variants'danger'Alert variant to display

Changelog

Unspecified minor versions are for dependencies updates.

2.1.0

  • ✨ Message suffix added to simplify adding retry button (also described in example).

2.0.0

  • ✨ Allow to change prefix as string without redefining whole render message function.

1.0.0

  • 🎉 Initial version

Keywords

FAQs

Last updated on 27 Apr 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc