react-error-boundary
Advanced tools
Comparing version 4.0.9 to 4.0.10
@@ -26,3 +26,3 @@ 'use client'; | ||
} | ||
resetErrorBoundary(...args) { | ||
resetErrorBoundary() { | ||
const { | ||
@@ -32,3 +32,7 @@ error | ||
if (error !== null) { | ||
this.props.onReset?.({ | ||
var _this$props$onReset, _this$props; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
(_this$props$onReset = (_this$props = this.props).onReset) === null || _this$props$onReset === void 0 ? void 0 : _this$props$onReset.call(_this$props, { | ||
args, | ||
@@ -41,3 +45,4 @@ reason: "imperative-api" | ||
componentDidCatch(error, info) { | ||
this.props.onError?.(error, info); | ||
var _this$props$onError, _this$props2; | ||
(_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2, error, info); | ||
} | ||
@@ -58,3 +63,4 @@ componentDidUpdate(prevProps, prevState) { | ||
if (didCatch && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) { | ||
this.props.onReset?.({ | ||
var _this$props$onReset2, _this$props3; | ||
(_this$props$onReset2 = (_this$props3 = this.props).onReset) === null || _this$props$onReset2 === void 0 ? void 0 : _this$props$onReset2.call(_this$props3, { | ||
next: resetKeys, | ||
@@ -103,3 +109,5 @@ prev: prevProps.resetKeys, | ||
} | ||
function hasArrayChanged(a = [], b = []) { | ||
function hasArrayChanged() { | ||
let a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
let b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index])); | ||
@@ -124,3 +132,3 @@ } | ||
resetBoundary: () => { | ||
context?.resetErrorBoundary(); | ||
context === null || context === void 0 ? void 0 : context.resetErrorBoundary(); | ||
setState({ | ||
@@ -135,3 +143,3 @@ error: null, | ||
}) | ||
}), [context?.resetErrorBoundary]); | ||
}), [context === null || context === void 0 ? void 0 : context.resetErrorBoundary]); | ||
if (state.hasError) { | ||
@@ -151,3 +159,3 @@ throw state.error; | ||
const name = component.displayName || component.name || "Unknown"; | ||
Wrapped.displayName = `withErrorBoundary(${name})`; | ||
Wrapped.displayName = "withErrorBoundary(".concat(name, ")"); | ||
return Wrapped; | ||
@@ -154,0 +162,0 @@ } |
@@ -22,3 +22,3 @@ 'use client'; | ||
} | ||
resetErrorBoundary(...args) { | ||
resetErrorBoundary() { | ||
const { | ||
@@ -28,3 +28,7 @@ error | ||
if (error !== null) { | ||
this.props.onReset?.({ | ||
var _this$props$onReset, _this$props; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
(_this$props$onReset = (_this$props = this.props).onReset) === null || _this$props$onReset === void 0 ? void 0 : _this$props$onReset.call(_this$props, { | ||
args, | ||
@@ -37,3 +41,4 @@ reason: "imperative-api" | ||
componentDidCatch(error, info) { | ||
this.props.onError?.(error, info); | ||
var _this$props$onError, _this$props2; | ||
(_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2, error, info); | ||
} | ||
@@ -54,3 +59,4 @@ componentDidUpdate(prevProps, prevState) { | ||
if (didCatch && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) { | ||
this.props.onReset?.({ | ||
var _this$props$onReset2, _this$props3; | ||
(_this$props$onReset2 = (_this$props3 = this.props).onReset) === null || _this$props$onReset2 === void 0 ? void 0 : _this$props$onReset2.call(_this$props3, { | ||
next: resetKeys, | ||
@@ -99,3 +105,5 @@ prev: prevProps.resetKeys, | ||
} | ||
function hasArrayChanged(a = [], b = []) { | ||
function hasArrayChanged() { | ||
let a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
let b = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; | ||
return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index])); | ||
@@ -120,3 +128,3 @@ } | ||
resetBoundary: () => { | ||
context?.resetErrorBoundary(); | ||
context === null || context === void 0 ? void 0 : context.resetErrorBoundary(); | ||
setState({ | ||
@@ -131,3 +139,3 @@ error: null, | ||
}) | ||
}), [context?.resetErrorBoundary]); | ||
}), [context === null || context === void 0 ? void 0 : context.resetErrorBoundary]); | ||
if (state.hasError) { | ||
@@ -147,3 +155,3 @@ throw state.error; | ||
const name = component.displayName || component.name || "Unknown"; | ||
Wrapped.displayName = `withErrorBoundary(${name})`; | ||
Wrapped.displayName = "withErrorBoundary(".concat(name, ")"); | ||
return Wrapped; | ||
@@ -150,0 +158,0 @@ } |
{ | ||
"name": "react-error-boundary", | ||
"version": "4.0.9", | ||
"version": "4.0.10", | ||
"description": "Simple reusable React error boundary component", | ||
@@ -46,2 +46,3 @@ "author": "Brian Vaughn <brian.david.vaughn@gmail.com>", | ||
"devDependencies": { | ||
"@babel/preset-env": "^7.22.5", | ||
"@babel/preset-typescript": "^7.21.5", | ||
@@ -48,0 +49,0 @@ "@preconstruct/cli": "^2.7.0", |
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
22797
373
13