πŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more β†’
Socket
Book a DemoInstallSign in
Socket

react-error-boundary

Package Overview
Dependencies
Maintainers
2
Versions
52
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

to
3.1.3

2

dist/index.d.ts

@@ -58,4 +58,4 @@ import * as React from 'react';

declare function withErrorBoundary<P>(Component: React.ComponentType<P>, errorBoundaryProps: ErrorBoundaryProps): React.ComponentType<P>;
declare function useErrorHandler<P = Error>(givenError?: P | null | undefined): React.Dispatch<React.SetStateAction<P | null>>;
declare function useErrorHandler(givenError?: unknown): (error: unknown) => void;
export { ErrorBoundary, withErrorBoundary, useErrorHandler };
export type { FallbackProps, ErrorBoundaryPropsWithComponent, ErrorBoundaryPropsWithRender, ErrorBoundaryPropsWithFallback, ErrorBoundaryProps, };

@@ -175,4 +175,4 @@ 'use strict';

if (givenError) throw givenError;
if (error) throw error;
if (givenError != null) throw givenError;
if (error != null) throw error;
return setError;

@@ -179,0 +179,0 @@ }

@@ -146,4 +146,4 @@ import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';

if (givenError) throw givenError;
if (error) throw error;
if (givenError != null) throw givenError;
if (error != null) throw error;
return setError;

@@ -150,0 +150,0 @@ }

@@ -186,4 +186,4 @@ (function (global, factory) {

if (givenError) throw givenError;
if (error) throw error;
if (givenError != null) throw givenError;
if (error != null) throw error;
return setError;

@@ -190,0 +190,0 @@ }

@@ -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){if(r&&r.__esModule)return r;var e=Object.create(null);return r&&Object.keys(r).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:function(){return r[t]}})}})),e.default=r,Object.freeze(e)}var n=t(e);function o(r,e){return(o=Object.setPrototypeOf||function(r,e){return r.__proto__=e,r})(r,e)}var a={error:null},i=function(r){var e,t;function i(){for(var e,t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return(e=r.call.apply(r,[this].concat(n))||this).state=a,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=i).prototype=Object.create(t.prototype),e.prototype.constructor=e,o(e,t),i.getDerivedStateFromError=function(r){return{error:r}};var u=i.prototype;return u.reset=function(){this.updatedWithError=!1,this.setState(a)},u.componentDidCatch=function(r,e){var t,n;null==(t=(n=this.props).onError)||t.call(n,r,e)},u.componentDidMount=function(){null!==this.state.error&&(this.updatedWithError=!0)},u.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},u.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.isValidElement(a))return a;if("function"==typeof t)return t(i);if(o)return n.createElement(o,i);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},i}(n.Component);r.ErrorBoundary=i,r.useErrorHandler=function(r){var e=n.useState(null),t=e[0],o=e[1];if(r)throw r;if(t)throw t;return o},r.withErrorBoundary=function(r,e){var t=function(t){return n.createElement(i,e,n.createElement(r,t))},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";function t(r){if(r&&r.__esModule)return r;var e=Object.create(null);return r&&Object.keys(r).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:function(){return r[t]}})}})),e.default=r,Object.freeze(e)}var n=t(e);function o(r,e){return(o=Object.setPrototypeOf||function(r,e){return r.__proto__=e,r})(r,e)}var a={error:null},i=function(r){var e,t;function i(){for(var e,t=arguments.length,n=new Array(t),o=0;o<t;o++)n[o]=arguments[o];return(e=r.call.apply(r,[this].concat(n))||this).state=a,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=i).prototype=Object.create(t.prototype),e.prototype.constructor=e,o(e,t),i.getDerivedStateFromError=function(r){return{error:r}};var u=i.prototype;return u.reset=function(){this.updatedWithError=!1,this.setState(a)},u.componentDidCatch=function(r,e){var t,n;null==(t=(n=this.props).onError)||t.call(n,r,e)},u.componentDidMount=function(){null!==this.state.error&&(this.updatedWithError=!0)},u.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},u.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.isValidElement(a))return a;if("function"==typeof t)return t(i);if(o)return n.createElement(o,i);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},i}(n.Component);r.ErrorBoundary=i,r.useErrorHandler=function(r){var e=n.useState(null),t=e[0],o=e[1];if(null!=r)throw r;if(null!=t)throw t;return o},r.withErrorBoundary=function(r,e){var t=function(t){return n.createElement(i,e,n.createElement(r,t))},o=r.displayName||r.name||"Unknown";return t.displayName="withErrorBoundary("+o+")",t},Object.defineProperty(r,"__esModule",{value:!0})}));
//# sourceMappingURL=react-error-boundary.umd.min.js.map
{
"name": "react-error-boundary",
"version": "3.1.2",
"version": "3.1.3",
"description": "Simple reusable React error boundary component",

@@ -5,0 +5,0 @@ "main": "dist/react-error-boundary.cjs.js",

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

### `useErrorHandler(error?: Error)`
### `useErrorHandler(error?: unknown)`

@@ -295,0 +295,0 @@ React's error boundaries feature is limited in that the boundaries can only

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet