📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP

error-boundary-jsx

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

error-boundary-jsx

React (JS) string formatting

2.0.6
latest
Version published
Maintainers
1
Created

npm npm bundle size Build Status codecov dependabot badge semantic-release Commitizen friendly

error-boundary-jsx

Handle errors on wrapped component and provide a fall back.

yarn add error-boundary-jsx

# or with npm

npm install error-boundary-jsx --save

Handle errors for specific use case of component.

import ErrorBoundary from 'error-boundary-jsx'

<ErrorBoundary onError={componentErrorHandler} name="component name" FallbackComponent={CustomFallbackComponent}>
    ...component tree to handle errors
</ErrorBoundary>

withErrorBoundary() HOC

HOC for error handling every use case of a component.

import withErrorBoundary from 'error-boundary-jsx'

const componentErrorHandler = {
    handleComponentError(error: Error, name: string, stack: string): void {
        ...log error
    }
}

withErrorBoundary(Component, componentErrorHandler)
API
proptyperequireddefaultValueDescription
componentReact.ComponentTypetrue-A component that we want to bind error boundary jsx to
namestringtrue-Component name to identify in stack message
onError(name: string, error: Error, stack: string) => voidtrue-Error callback handler
FallbackComponentReact.ComponentTypefalse-A fallback component when error occurs

FAQs

Package last updated on 14 Sep 2020

Did you know?

Socket

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