Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More โ†’
Socket
Sign inDemoInstall
Socket

react-error-boundary

Package Overview
Dependencies
Maintainers
2
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-error-boundary - npm Package Compare versions

Comparing version 3.0.2 to 3.1.0

dist/index.d.ts

27

dist/react-error-boundary.cjs.js

@@ -11,3 +11,2 @@ 'use strict';

var _inheritsLoose__default = /*#__PURE__*/_interopDefaultLegacy(_inheritsLoose);
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

@@ -103,3 +102,4 @@ var changedArray = function (a, b) {

_proto.render = function render() {
var error = this.state.error;
var error = this.state.error; // @ts-expect-error ts(2339) (at least one of these will be defined though, and we check for their existance)
var _this$props4 = this.props,

@@ -111,3 +111,3 @@ fallbackRender = _this$props4.fallbackRender,

if (error !== null) {
var props = {
var _props = {
error: error,

@@ -117,8 +117,8 @@ resetErrorBoundary: this.resetErrorBoundary

if ( /*#__PURE__*/React__default['default'].isValidElement(fallback)) {
if ( /*#__PURE__*/React.isValidElement(fallback)) {
return fallback;
} else if (typeof fallbackRender === 'function') {
return fallbackRender(props);
return fallbackRender(_props);
} else if (FallbackComponent) {
return /*#__PURE__*/React__default['default'].createElement(FallbackComponent, props);
return /*#__PURE__*/React.createElement(FallbackComponent, _props);
} else {

@@ -133,8 +133,8 @@ throw new Error('react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop');

return ErrorBoundary;
}(React__default['default'].Component);
}(React.Component);
function withErrorBoundary(Component, errorBoundaryProps) {
function Wrapped(props) {
return /*#__PURE__*/React__default['default'].createElement(ErrorBoundary, errorBoundaryProps, /*#__PURE__*/React__default['default'].createElement(Component, props));
} // Format for display in DevTools
var Wrapped = function (props) {
return /*#__PURE__*/React.createElement(ErrorBoundary, errorBoundaryProps, /*#__PURE__*/React.createElement(Component, props));
}; // Format for display in DevTools

@@ -148,3 +148,3 @@

function useErrorHandler(givenError) {
var _React$useState = React__default['default'].useState(null),
var _React$useState = React.useState(null),
error = _React$useState[0],

@@ -157,2 +157,7 @@ setError = _React$useState[1];

}
/*
eslint
@typescript-eslint/no-throw-literal: "off",
@typescript-eslint/prefer-nullish-coalescing: "off"
*/

@@ -159,0 +164,0 @@ exports.ErrorBoundary = ErrorBoundary;

import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
import React from 'react';
import { isValidElement, createElement, Component, useState } from 'react';

@@ -93,3 +93,4 @@ var changedArray = function (a, b) {

_proto.render = function render() {
var error = this.state.error;
var error = this.state.error; // @ts-expect-error ts(2339) (at least one of these will be defined though, and we check for their existance)
var _this$props4 = this.props,

@@ -101,3 +102,3 @@ fallbackRender = _this$props4.fallbackRender,

if (error !== null) {
var props = {
var _props = {
error: error,

@@ -107,8 +108,8 @@ resetErrorBoundary: this.resetErrorBoundary

if ( /*#__PURE__*/React.isValidElement(fallback)) {
if ( /*#__PURE__*/isValidElement(fallback)) {
return fallback;
} else if (typeof fallbackRender === 'function') {
return fallbackRender(props);
return fallbackRender(_props);
} else if (FallbackComponent) {
return /*#__PURE__*/React.createElement(FallbackComponent, props);
return /*#__PURE__*/createElement(FallbackComponent, _props);
} else {

@@ -123,8 +124,8 @@ throw new Error('react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop');

return ErrorBoundary;
}(React.Component);
}(Component);
function withErrorBoundary(Component, errorBoundaryProps) {
function Wrapped(props) {
return /*#__PURE__*/React.createElement(ErrorBoundary, errorBoundaryProps, /*#__PURE__*/React.createElement(Component, props));
} // Format for display in DevTools
var Wrapped = function (props) {
return /*#__PURE__*/createElement(ErrorBoundary, errorBoundaryProps, /*#__PURE__*/createElement(Component, props));
}; // Format for display in DevTools

@@ -138,3 +139,3 @@

function useErrorHandler(givenError) {
var _React$useState = React.useState(null),
var _React$useState = useState(null),
error = _React$useState[0],

@@ -147,3 +148,8 @@ setError = _React$useState[1];

}
/*
eslint
@typescript-eslint/no-throw-literal: "off",
@typescript-eslint/prefer-nullish-coalescing: "off"
*/
export { ErrorBoundary, useErrorHandler, withErrorBoundary };

@@ -7,6 +7,2 @@ (function (global, factory) {

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
function _inheritsLoose(subClass, superClass) {

@@ -107,3 +103,4 @@ subClass.prototype = Object.create(superClass.prototype);

_proto.render = function render() {
var error = this.state.error;
var error = this.state.error; // @ts-expect-error ts(2339) (at least one of these will be defined though, and we check for their existance)
var _this$props4 = this.props,

@@ -115,3 +112,3 @@ fallbackRender = _this$props4.fallbackRender,

if (error !== null) {
var props = {
var _props = {
error: error,

@@ -121,8 +118,8 @@ resetErrorBoundary: this.resetErrorBoundary

if ( /*#__PURE__*/React__default['default'].isValidElement(fallback)) {
if ( /*#__PURE__*/React.isValidElement(fallback)) {
return fallback;
} else if (typeof fallbackRender === 'function') {
return fallbackRender(props);
return fallbackRender(_props);
} else if (FallbackComponent) {
return /*#__PURE__*/React__default['default'].createElement(FallbackComponent, props);
return /*#__PURE__*/React.createElement(FallbackComponent, _props);
} else {

@@ -137,8 +134,8 @@ throw new Error('react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop');

return ErrorBoundary;
}(React__default['default'].Component);
}(React.Component);
function withErrorBoundary(Component, errorBoundaryProps) {
function Wrapped(props) {
return /*#__PURE__*/React__default['default'].createElement(ErrorBoundary, errorBoundaryProps, /*#__PURE__*/React__default['default'].createElement(Component, props));
} // Format for display in DevTools
var Wrapped = function (props) {
return /*#__PURE__*/React.createElement(ErrorBoundary, errorBoundaryProps, /*#__PURE__*/React.createElement(Component, props));
}; // Format for display in DevTools

@@ -152,3 +149,3 @@

function useErrorHandler(givenError) {
var _React$useState = React__default['default'].useState(null),
var _React$useState = React.useState(null),
error = _React$useState[0],

@@ -161,2 +158,7 @@ setError = _React$useState[1];

}
/*
eslint
@typescript-eslint/no-throw-literal: "off",
@typescript-eslint/prefer-nullish-coalescing: "off"
*/

@@ -163,0 +165,0 @@ exports.ErrorBoundary = ErrorBoundary;

@@ -1,2 +0,2 @@

!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self).ReactErrorBoundary={},r.React)}(this,(function(r,e){"use strict";function t(r){return r&&"object"==typeof r&&"default"in r?r:{default:r}}var n=t(e);var o={error:null},a=function(r){var e,t;function a(){for(var e,t=arguments.length,n=new Array(t),a=0;a<t;a++)n[a]=arguments[a];return(e=r.call.apply(r,[this].concat(n))||this).state=o,e.updatedWithError=!1,e.resetErrorBoundary=function(){for(var r,t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];null==e.props.onReset||(r=e.props).onReset.apply(r,n),e.reset()},e}t=r,(e=a).prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t,a.getDerivedStateFromError=function(r){return{error:r}};var i=a.prototype;return i.reset=function(){this.updatedWithError=!1,this.setState(o)},i.componentDidCatch=function(r,e){var t,n;null==(t=(n=this.props).onError)||t.call(n,r,e)},i.componentDidUpdate=function(r){var e,t,n,o,a=this.state.error,i=this.props.resetKeys;null===a||this.updatedWithError?null!==a&&(void 0===(n=r.resetKeys)&&(n=[]),void 0===(o=i)&&(o=[]),n.length!==o.length||n.some((function(r,e){return!Object.is(r,o[e])})))&&(null==(e=(t=this.props).onResetKeysChange)||e.call(t,r.resetKeys,i),this.reset()):this.updatedWithError=!0},i.render=function(){var r=this.state.error,e=this.props,t=e.fallbackRender,o=e.FallbackComponent,a=e.fallback;if(null!==r){var i={error:r,resetErrorBoundary:this.resetErrorBoundary};if(n.default.isValidElement(a))return a;if("function"==typeof t)return t(i);if(o)return n.default.createElement(o,i);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},a}(n.default.Component);r.ErrorBoundary=a,r.useErrorHandler=function(r){var e=n.default.useState(null),t=e[0],o=e[1];if(r)throw r;if(t)throw t;return o},r.withErrorBoundary=function(r,e){function t(t){return n.default.createElement(a,e,n.default.createElement(r,t))}var o=r.displayName||r.name||"Unknown";return t.displayName="withErrorBoundary("+o+")",t},Object.defineProperty(r,"__esModule",{value:!0})}));
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],e):e((r="undefined"!=typeof globalThis?globalThis:r||self).ReactErrorBoundary={},r.React)}(this,(function(r,e){"use strict";var t={error:null},o=function(r){var o,n;function a(){for(var e,o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];return(e=r.call.apply(r,[this].concat(n))||this).state=t,e.updatedWithError=!1,e.resetErrorBoundary=function(){for(var r,t=arguments.length,o=new Array(t),n=0;n<t;n++)o[n]=arguments[n];null==e.props.onReset||(r=e.props).onReset.apply(r,o),e.reset()},e}n=r,(o=a).prototype=Object.create(n.prototype),o.prototype.constructor=o,o.__proto__=n,a.getDerivedStateFromError=function(r){return{error:r}};var i=a.prototype;return i.reset=function(){this.updatedWithError=!1,this.setState(t)},i.componentDidCatch=function(r,e){var t,o;null==(t=(o=this.props).onError)||t.call(o,r,e)},i.componentDidUpdate=function(r){var e,t,o,n,a=this.state.error,i=this.props.resetKeys;null===a||this.updatedWithError?null!==a&&(void 0===(o=r.resetKeys)&&(o=[]),void 0===(n=i)&&(n=[]),o.length!==n.length||o.some((function(r,e){return!Object.is(r,n[e])})))&&(null==(e=(t=this.props).onResetKeysChange)||e.call(t,r.resetKeys,i),this.reset()):this.updatedWithError=!0},i.render=function(){var r=this.state.error,t=this.props,o=t.fallbackRender,n=t.FallbackComponent,a=t.fallback;if(null!==r){var i={error:r,resetErrorBoundary:this.resetErrorBoundary};if(e.isValidElement(a))return a;if("function"==typeof o)return o(i);if(n)return e.createElement(n,i);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},a}(e.Component);r.ErrorBoundary=o,r.useErrorHandler=function(r){var t=e.useState(null),o=t[0],n=t[1];if(r)throw r;if(o)throw o;return n},r.withErrorBoundary=function(r,t){var n=function(n){return e.createElement(o,t,e.createElement(r,n))},a=r.displayName||r.name||"Unknown";return n.displayName="withErrorBoundary("+a+")",n},Object.defineProperty(r,"__esModule",{value:!0})}));
//# sourceMappingURL=react-error-boundary.umd.min.js.map
{
"name": "react-error-boundary",
"version": "3.0.2",
"version": "3.1.0",
"description": "Simple reusable React error boundary component",

@@ -8,3 +8,3 @@ "main": "dist/react-error-boundary.cjs.js",

"browser": "dist/react-error-boundary.umd.js",
"types": "index.d.ts",
"types": "dist/index.d.ts",
"sideEffects": false,

@@ -31,4 +31,3 @@ "keywords": [

"files": [
"dist",
"index.d.ts"
"dist"
],

@@ -41,15 +40,18 @@ "scripts": {

"test:update": "npm test -- --updateSnapshot --coverage",
"typecheck": "kcd-scripts typecheck",
"validate": "kcd-scripts validate"
},
"dependencies": {
"@babel/runtime": "^7.11.2"
"@babel/runtime": "^7.12.5"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.0.2",
"@testing-library/user-event": "^12.1.4",
"kcd-scripts": "^6.3.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"typescript": "^4.0.2"
"@testing-library/jest-dom": "^5.11.6",
"@testing-library/react": "^11.2.2",
"@testing-library/user-event": "^12.2.2",
"@types/jest": "^26.0.15",
"@types/react": "^17.0.0",
"kcd-scripts": "^7.3.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"typescript": "^4.1.2"
},

@@ -56,0 +58,0 @@ "peerDependencies": {

@@ -15,3 +15,2 @@ <div align="center">

[![MIT License][license-badge]][license]
[![PRs Welcome][prs-badge]][prs]

@@ -340,5 +339,3 @@ [![Code of Conduct][coc-badge]][coc]

<input id="name" />
<button type="submit"}>
get a greeting
</button>
<button type="submit">get a greeting</button>
</form>

@@ -430,4 +427,4 @@ )

[node]: https://nodejs.org
[build-badge]: https://img.shields.io/travis/bvaughn/react-error-boundary.svg?style=flat-square
[build]: https://travis-ci.org/bvaughn/react-error-boundary
[build-badge]: https://img.shields.io/github/workflow/status/bvaughn/react-error-boundary/validate?logo=github&style=flat-square
[build]: https://github.com/bvaughn/react-error-boundary/actions?query=workflow%3Avalidate
[coverage-badge]: https://img.shields.io/codecov/c/github/bvaughn/react-error-boundary.svg?style=flat-square

@@ -438,9 +435,9 @@ [coverage]: https://codecov.io/github/bvaughn/react-error-boundary

[downloads-badge]: https://img.shields.io/npm/dm/react-error-boundary.svg?style=flat-square
[npmtrends]: http://www.npmtrends.com/react-error-boundary
[npmtrends]: https://www.npmtrends.com/react-error-boundary
[license-badge]: https://img.shields.io/npm/l/react-error-boundary.svg?style=flat-square
[license]: https://github.com/bvaughn/react-error-boundary/blob/master/LICENSE
[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
[prs]: http://makeapullrequest.com
[prs]: https://makeapullrequest.com
[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
[coc]: https://github.com/bvaughn/react-error-boundary/blob/master/other/CODE_OF_CONDUCT.md
[coc]: https://github.com/bvaughn/react-error-boundary/blob/master/CODE_OF_CONDUCT.md
[bugs]: https://github.com/bvaughn/react-error-boundary/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Acreated-desc+label%3Abug

@@ -447,0 +444,0 @@ [requests]: https://github.com/bvaughn/react-error-boundary/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc+label%3Aenhancement

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc