react-error-boundary
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -35,12 +35,18 @@ 'use strict'; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
_args[_key] = arguments[_key]; | ||
} | ||
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this; | ||
_this = _React$Component.call.apply(_React$Component, [this].concat(_args)) || this; | ||
_this.state = initialState; | ||
_this.resetErrorBoundary = function () { | ||
_this.props.onReset == null ? void 0 : _this.props.onReset(); | ||
var _this$props; | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
_this.props.onReset == null ? void 0 : (_this$props = _this.props).onReset.apply(_this$props, args); | ||
_this.setState(initialState); | ||
@@ -55,5 +61,5 @@ }; | ||
_proto.componentDidCatch = function componentDidCatch(error, info) { | ||
var _this$props$onError, _this$props; | ||
var _this$props$onError, _this$props2; | ||
(_this$props$onError = (_this$props = this.props).onError) == null ? void 0 : _this$props$onError.call(_this$props, error, info == null ? void 0 : info.componentStack); | ||
(_this$props$onError = (_this$props2 = this.props).onError) == null ? void 0 : _this$props$onError.call(_this$props2, error, info == null ? void 0 : info.componentStack); | ||
this.setState({ | ||
@@ -70,3 +76,6 @@ error: error, | ||
if (error !== null && changedArray(prevProps.resetKeys, resetKeys)) { | ||
this.resetErrorBoundary(); | ||
var _this$props$onResetKe, _this$props3; | ||
(_this$props$onResetKe = (_this$props3 = this.props).onResetKeysChange) == null ? void 0 : _this$props$onResetKe.call(_this$props3, prevProps.resetKeys, resetKeys); | ||
this.setState(initialState); | ||
} | ||
@@ -79,6 +88,6 @@ }; | ||
info = _this$state.info; | ||
var _this$props2 = this.props, | ||
fallbackRender = _this$props2.fallbackRender, | ||
FallbackComponent = _this$props2.FallbackComponent, | ||
fallback = _this$props2.fallback; | ||
var _this$props4 = this.props, | ||
fallbackRender = _this$props4.fallbackRender, | ||
FallbackComponent = _this$props4.FallbackComponent, | ||
fallback = _this$props4.fallback; | ||
@@ -85,0 +94,0 @@ if (error !== null) { |
@@ -29,12 +29,18 @@ import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose'; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
_args[_key] = arguments[_key]; | ||
} | ||
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this; | ||
_this = _React$Component.call.apply(_React$Component, [this].concat(_args)) || this; | ||
_this.state = initialState; | ||
_this.resetErrorBoundary = function () { | ||
_this.props.onReset == null ? void 0 : _this.props.onReset(); | ||
var _this$props; | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
_this.props.onReset == null ? void 0 : (_this$props = _this.props).onReset.apply(_this$props, args); | ||
_this.setState(initialState); | ||
@@ -49,5 +55,5 @@ }; | ||
_proto.componentDidCatch = function componentDidCatch(error, info) { | ||
var _this$props$onError, _this$props; | ||
var _this$props$onError, _this$props2; | ||
(_this$props$onError = (_this$props = this.props).onError) == null ? void 0 : _this$props$onError.call(_this$props, error, info == null ? void 0 : info.componentStack); | ||
(_this$props$onError = (_this$props2 = this.props).onError) == null ? void 0 : _this$props$onError.call(_this$props2, error, info == null ? void 0 : info.componentStack); | ||
this.setState({ | ||
@@ -64,3 +70,6 @@ error: error, | ||
if (error !== null && changedArray(prevProps.resetKeys, resetKeys)) { | ||
this.resetErrorBoundary(); | ||
var _this$props$onResetKe, _this$props3; | ||
(_this$props$onResetKe = (_this$props3 = this.props).onResetKeysChange) == null ? void 0 : _this$props$onResetKe.call(_this$props3, prevProps.resetKeys, resetKeys); | ||
this.setState(initialState); | ||
} | ||
@@ -73,6 +82,6 @@ }; | ||
info = _this$state.info; | ||
var _this$props2 = this.props, | ||
fallbackRender = _this$props2.fallbackRender, | ||
FallbackComponent = _this$props2.FallbackComponent, | ||
fallback = _this$props2.fallback; | ||
var _this$props4 = this.props, | ||
fallbackRender = _this$props4.fallbackRender, | ||
FallbackComponent = _this$props4.FallbackComponent, | ||
fallback = _this$props4.fallback; | ||
@@ -79,0 +88,0 @@ if (error !== null) { |
@@ -40,12 +40,18 @@ (function (global, factory) { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
_args[_key] = arguments[_key]; | ||
} | ||
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this; | ||
_this = _React$Component.call.apply(_React$Component, [this].concat(_args)) || this; | ||
_this.state = initialState; | ||
_this.resetErrorBoundary = function () { | ||
_this.props.onReset == null ? void 0 : _this.props.onReset(); | ||
var _this$props; | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
_this.props.onReset == null ? void 0 : (_this$props = _this.props).onReset.apply(_this$props, args); | ||
_this.setState(initialState); | ||
@@ -60,5 +66,5 @@ }; | ||
_proto.componentDidCatch = function componentDidCatch(error, info) { | ||
var _this$props$onError, _this$props; | ||
var _this$props$onError, _this$props2; | ||
(_this$props$onError = (_this$props = this.props).onError) == null ? void 0 : _this$props$onError.call(_this$props, error, info == null ? void 0 : info.componentStack); | ||
(_this$props$onError = (_this$props2 = this.props).onError) == null ? void 0 : _this$props$onError.call(_this$props2, error, info == null ? void 0 : info.componentStack); | ||
this.setState({ | ||
@@ -75,3 +81,6 @@ error: error, | ||
if (error !== null && changedArray(prevProps.resetKeys, resetKeys)) { | ||
this.resetErrorBoundary(); | ||
var _this$props$onResetKe, _this$props3; | ||
(_this$props$onResetKe = (_this$props3 = this.props).onResetKeysChange) == null ? void 0 : _this$props$onResetKe.call(_this$props3, prevProps.resetKeys, resetKeys); | ||
this.setState(initialState); | ||
} | ||
@@ -84,6 +93,6 @@ }; | ||
info = _this$state.info; | ||
var _this$props2 = this.props, | ||
fallbackRender = _this$props2.fallbackRender, | ||
FallbackComponent = _this$props2.FallbackComponent, | ||
fallback = _this$props2.fallback; | ||
var _this$props4 = this.props, | ||
fallbackRender = _this$props4.fallbackRender, | ||
FallbackComponent = _this$props4.FallbackComponent, | ||
fallback = _this$props4.fallback; | ||
@@ -90,0 +99,0 @@ if (error !== null) { |
@@ -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=r||self).ReactErrorBoundary={},r.React)}(this,(function(r,e){"use strict";e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;var t={error:null,info: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.resetErrorBoundary=function(){null==e.props.onReset||e.props.onReset(),e.setState(t)},e}n=r,(o=a).prototype=Object.create(n.prototype),o.prototype.constructor=o,o.__proto__=n;var i=a.prototype;return i.componentDidCatch=function(r,e){var t,o;null==(t=(o=this.props).onError)||t.call(o,r,null==e?void 0:e.componentStack),this.setState({error:r,info:e})},i.componentDidUpdate=function(r){var e,t,o=this.state.error,n=this.props.resetKeys;null!==o&&(void 0===(e=r.resetKeys)&&(e=[]),void 0===(t=n)&&(t=[]),e.some((function(r,e){return!Object.is(r,t[e])})))&&this.resetErrorBoundary()},i.render=function(){var r=this.state,t=r.error,o=r.info,n=this.props,a=n.fallbackRender,i=n.FallbackComponent,c=n.fallback;if(null!==t){var l={componentStack:null==o?void 0:o.componentStack,error:t,resetErrorBoundary:this.resetErrorBoundary};if(e.isValidElement(c))return c;if("function"==typeof a)return a(l);if("function"==typeof i)return e.createElement(i,l);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.withErrorBoundary=function(r,t){function n(n){return e.createElement(o,t,e.createElement(r,n))}var a=r.displayName||r.name||"Unknown";return n.displayName="withErrorBoundary("+a+")",n},Object.defineProperty(r,"__esModule",{value:!0})})); | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],r):r((e=e||self).ReactErrorBoundary={},e.React)}(this,(function(e,r){"use strict";r=r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r;var t={error:null,info:null},o=function(e){var o,n;function a(){for(var r,o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];return(r=e.call.apply(e,[this].concat(n))||this).state=t,r.resetErrorBoundary=function(){for(var e,o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];null==r.props.onReset||(e=r.props).onReset.apply(e,n),r.setState(t)},r}n=e,(o=a).prototype=Object.create(n.prototype),o.prototype.constructor=o,o.__proto__=n;var i=a.prototype;return i.componentDidCatch=function(e,r){var t,o;null==(t=(o=this.props).onError)||t.call(o,e,null==r?void 0:r.componentStack),this.setState({error:e,info:r})},i.componentDidUpdate=function(e){var r,o,n,a,i=this.state.error,l=this.props.resetKeys;null!==i&&(void 0===(n=e.resetKeys)&&(n=[]),void 0===(a=l)&&(a=[]),n.some((function(e,r){return!Object.is(e,a[r])})))&&(null==(r=(o=this.props).onResetKeysChange)||r.call(o,e.resetKeys,l),this.setState(t))},i.render=function(){var e=this.state,t=e.error,o=e.info,n=this.props,a=n.fallbackRender,i=n.FallbackComponent,l=n.fallback;if(null!==t){var s={componentStack:null==o?void 0:o.componentStack,error:t,resetErrorBoundary:this.resetErrorBoundary};if(r.isValidElement(l))return l;if("function"==typeof a)return a(s);if("function"==typeof i)return r.createElement(i,s);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},a}(r.Component);e.ErrorBoundary=o,e.withErrorBoundary=function(e,t){function n(n){return r.createElement(o,t,r.createElement(e,n))}var a=e.displayName||e.name||"Unknown";return n.displayName="withErrorBoundary("+a+")",n},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=react-error-boundary.umd.min.js.map |
{ | ||
"name": "react-error-boundary", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Simple reusable React error boundary component", | ||
@@ -5,0 +5,0 @@ "main": "dist/react-error-boundary.cjs.js", |
@@ -48,2 +48,3 @@ <div align="center"> | ||
- [`resetKeys`](#resetkeys) | ||
- [`onResetKeysChange`](#onresetkeyschange) | ||
- [Issues](#issues) | ||
@@ -277,2 +278,7 @@ - [๐ Bugs](#-bugs) | ||
`onReset` will be called with whatever `resetErrorBoundary` is called with. | ||
**Important**: `onReset` will _not_ be called when reset happens from a change | ||
in `resetKeys`. Use `onResetKeysChange` for that. | ||
### `resetKeys` | ||
@@ -288,2 +294,7 @@ | ||
### `onResetKeysChange` | ||
This is called when the `resetKeys` are changed (triggering a reset of the | ||
`ErrorBoundary`). It's called with the `prevResetKeys` and the `resetKeys`. | ||
## Issues | ||
@@ -290,0 +301,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37784
299
340