react-error-boundary 3.1.2 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/react-error-boundary.cjs.js +2 -2
- package/dist/react-error-boundary.esm.js +2 -2
- package/dist/react-error-boundary.umd.js +2 -2
- package/dist/react-error-boundary.umd.js.map +1 -1
- package/dist/react-error-boundary.umd.min.js +1 -1
- package/dist/react-error-boundary.umd.min.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -289,7 +289,7 @@ See the recovery examples above.
|
|
|
289
289
|
This is called when the `resetKeys` are changed (triggering a reset of the
|
|
290
290
|
`ErrorBoundary`). It's called with the `prevResetKeys` and the `resetKeys`.
|
|
291
291
|
|
|
292
|
-
### `useErrorHandler(error?:
|
|
292
|
+
### `useErrorHandler(error?: unknown)`
|
|
293
293
|
|
|
294
294
|
React's error boundaries feature is limited in that the boundaries can only
|
|
295
295
|
handle errors thrown during React's lifecycles. To quote
|
package/dist/index.d.ts
CHANGED
|
@@ -55,6 +55,6 @@ declare class ErrorBoundary extends React.Component<React.PropsWithRef<React.Pro
|
|
|
55
55
|
render(): React.ReactNode;
|
|
56
56
|
}
|
|
57
57
|
declare function withErrorBoundary<P>(Component: React.ComponentType<P>, errorBoundaryProps: ErrorBoundaryProps): React.ComponentType<P>;
|
|
58
|
-
declare function useErrorHandler
|
|
58
|
+
declare function useErrorHandler(givenError?: unknown): (error: unknown) => void;
|
|
59
59
|
export { ErrorBoundary, withErrorBoundary, useErrorHandler };
|
|
60
60
|
export type { FallbackProps, ErrorBoundaryPropsWithComponent, ErrorBoundaryPropsWithRender, ErrorBoundaryPropsWithFallback, ErrorBoundaryProps, };
|
|
@@ -172,8 +172,8 @@ function useErrorHandler(givenError) {
|
|
|
172
172
|
error = _React$useState[0],
|
|
173
173
|
setError = _React$useState[1];
|
|
174
174
|
|
|
175
|
-
if (givenError) throw givenError;
|
|
176
|
-
if (error) throw error;
|
|
175
|
+
if (givenError != null) throw givenError;
|
|
176
|
+
if (error != null) throw error;
|
|
177
177
|
return setError;
|
|
178
178
|
}
|
|
179
179
|
/*
|
|
@@ -143,8 +143,8 @@ function useErrorHandler(givenError) {
|
|
|
143
143
|
error = _React$useState[0],
|
|
144
144
|
setError = _React$useState[1];
|
|
145
145
|
|
|
146
|
-
if (givenError) throw givenError;
|
|
147
|
-
if (error) throw error;
|
|
146
|
+
if (givenError != null) throw givenError;
|
|
147
|
+
if (error != null) throw error;
|
|
148
148
|
return setError;
|
|
149
149
|
}
|
|
150
150
|
/*
|
|
@@ -183,8 +183,8 @@
|
|
|
183
183
|
error = _React$useState[0],
|
|
184
184
|
setError = _React$useState[1];
|
|
185
185
|
|
|
186
|
-
if (givenError) throw givenError;
|
|
187
|
-
if (error) throw error;
|
|
186
|
+
if (givenError != null) throw givenError;
|
|
187
|
+
if (error != null) throw error;
|
|
188
188
|
return setError;
|
|
189
189
|
}
|
|
190
190
|
/*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-error-boundary.umd.js","sources":["../node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","../src/index.tsx"],"sourcesContent":["export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}","import * as React from 'react'\n\nconst changedArray = (a: Array<unknown> = [], b: Array<unknown> = []) =>\n a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]))\n\ninterface FallbackProps {\n error: Error\n resetErrorBoundary: (...args: Array<unknown>) => void\n}\n\ninterface ErrorBoundaryPropsWithComponent {\n onResetKeysChange?: (\n prevResetKeys: Array<unknown> | undefined,\n resetKeys: Array<unknown> | undefined,\n ) => void\n onReset?: (...args: Array<unknown>) => void\n onError?: (error: Error, info: {componentStack: string}) => void\n resetKeys?: Array<unknown>\n fallback?: never\n FallbackComponent: React.ComponentType<FallbackProps>\n fallbackRender?: never\n}\n\ndeclare function FallbackRender(\n props: FallbackProps,\n): React.ReactElement<\n unknown,\n string | React.FunctionComponent | typeof React.Component\n> | null\n\ninterface ErrorBoundaryPropsWithRender {\n onResetKeysChange?: (\n prevResetKeys: Array<unknown> | undefined,\n resetKeys: Array<unknown> | undefined,\n ) => void\n onReset?: (...args: Array<unknown>) => void\n onError?: (error: Error, info: {componentStack: string}) => void\n resetKeys?: Array<unknown>\n fallback?: never\n FallbackComponent?: never\n fallbackRender: typeof FallbackRender\n}\n\ninterface ErrorBoundaryPropsWithFallback {\n onResetKeysChange?: (\n prevResetKeys: Array<unknown> | undefined,\n resetKeys: Array<unknown> | undefined,\n ) => void\n onReset?: (...args: Array<unknown>) => void\n onError?: (error: Error, info: {componentStack: string}) => void\n resetKeys?: Array<unknown>\n fallback: React.ReactElement<\n unknown,\n string | React.FunctionComponent | typeof React.Component\n > | null\n FallbackComponent?: never\n fallbackRender?: never\n}\n\ntype ErrorBoundaryProps =\n | ErrorBoundaryPropsWithFallback\n | ErrorBoundaryPropsWithComponent\n | ErrorBoundaryPropsWithRender\n\ntype ErrorBoundaryState = {error: Error | null}\n\nconst initialState: ErrorBoundaryState = {error: null}\n\nclass ErrorBoundary extends React.Component<\n React.PropsWithRef<React.PropsWithChildren<ErrorBoundaryProps>>,\n ErrorBoundaryState\n> {\n static getDerivedStateFromError(error: Error) {\n return {error}\n }\n\n state = initialState\n updatedWithError = false\n resetErrorBoundary = (...args: Array<unknown>) => {\n this.props.onReset?.(...args)\n this.reset()\n }\n\n reset() {\n this.updatedWithError = false\n this.setState(initialState)\n }\n\n componentDidCatch(error: Error, info: React.ErrorInfo) {\n this.props.onError?.(error, info)\n }\n\n componentDidMount() {\n const {error} = this.state\n\n if (error !== null) {\n this.updatedWithError = true\n }\n }\n\n componentDidUpdate(prevProps: ErrorBoundaryProps) {\n const {error} = this.state\n const {resetKeys} = this.props\n\n // There's an edge case where if the thing that triggered the error\n // happens to *also* be in the resetKeys array, we'd end up resetting\n // the error boundary immediately. This would likely trigger a second\n // error to be thrown.\n // So we make sure that we don't check the resetKeys on the first call\n // of cDU after the error is set\n if (error !== null && !this.updatedWithError) {\n this.updatedWithError = true\n return\n }\n\n if (error !== null && changedArray(prevProps.resetKeys, resetKeys)) {\n this.props.onResetKeysChange?.(prevProps.resetKeys, resetKeys)\n this.reset()\n }\n }\n\n render() {\n const {error} = this.state\n\n const {fallbackRender, FallbackComponent, fallback} = this.props\n\n if (error !== null) {\n const props = {\n error,\n resetErrorBoundary: this.resetErrorBoundary,\n }\n if (React.isValidElement(fallback)) {\n return fallback\n } else if (typeof fallbackRender === 'function') {\n return fallbackRender(props)\n } else if (FallbackComponent) {\n return <FallbackComponent {...props} />\n } else {\n throw new Error(\n 'react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop',\n )\n }\n }\n\n return this.props.children\n }\n}\n\nfunction withErrorBoundary<P>(\n Component: React.ComponentType<P>,\n errorBoundaryProps: ErrorBoundaryProps,\n): React.ComponentType<P> {\n const Wrapped: React.ComponentType<P> = props => {\n return (\n <ErrorBoundary {...errorBoundaryProps}>\n <Component {...props} />\n </ErrorBoundary>\n )\n }\n\n // Format for display in DevTools\n const name = Component.displayName || Component.name || 'Unknown'\n Wrapped.displayName = `withErrorBoundary(${name})`\n\n return Wrapped\n}\n\nfunction useErrorHandler<P = Error>(\n givenError?: P | null | undefined,\n): React.Dispatch<React.SetStateAction<P | null>> {\n const [error, setError] = React.useState<P | null>(null)\n if (givenError) throw givenError\n if (error) throw error\n return setError\n}\n\nexport {ErrorBoundary, withErrorBoundary, useErrorHandler}\nexport type {\n FallbackProps,\n ErrorBoundaryPropsWithComponent,\n ErrorBoundaryPropsWithRender,\n ErrorBoundaryPropsWithFallback,\n ErrorBoundaryProps,\n}\n\n/*\neslint\n @typescript-eslint/no-throw-literal: \"off\",\n @typescript-eslint/prefer-nullish-coalescing: \"off\"\n*/\n"],"names":["_setPrototypeOf","o","p","Object","setPrototypeOf","__proto__","_inheritsLoose","subClass","superClass","prototype","create","constructor","changedArray","a","b","length","some","item","index","is","initialState","error","ErrorBoundary","state","updatedWithError","resetErrorBoundary","args","props","onReset","reset","getDerivedStateFromError","setState","componentDidCatch","info","onError","componentDidMount","componentDidUpdate","prevProps","resetKeys","onResetKeysChange","render","fallbackRender","FallbackComponent","fallback","React","isValidElement","Error","children","Component","withErrorBoundary","errorBoundaryProps","Wrapped","name","displayName","useErrorHandler","givenError","useState","setError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAe,SAASA,eAAT,CAAyBC,CAAzB,EAA4BC,CAA5B,EAA+B;EAC5CF,EAAAA,eAAe,GAAGG,MAAM,CAACC,cAAP,IAAyB,SAASJ,eAAT,CAAyBC,CAAzB,EAA4BC,CAA5B,EAA+B;EACxED,IAAAA,CAAC,CAACI,SAAF,GAAcH,CAAd;EACA,WAAOD,CAAP;EACD,GAHD;;EAKA,SAAOD,eAAe,CAACC,CAAD,EAAIC,CAAJ,CAAtB;EACD;;ECNc,SAASI,cAAT,CAAwBC,QAAxB,EAAkCC,UAAlC,EAA8C;EAC3DD,EAAAA,QAAQ,CAACE,SAAT,GAAqBN,MAAM,CAACO,MAAP,CAAcF,UAAU,CAACC,SAAzB,CAArB;EACAF,EAAAA,QAAQ,CAACE,SAAT,CAAmBE,WAAnB,GAAiCJ,QAAjC;EACAH,EAAAA,eAAc,CAACG,QAAD,EAAWC,UAAX,CAAd;EACD;;ECHD,IAAMI,YAAY,GAAG,SAAfA,YAAe,CAACC,CAAD,EAAyBC,CAAzB;EAAA,MAACD,CAAD;EAACA,IAAAA,CAAD,GAAqB,EAArB;EAAA;;EAAA,MAAyB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xB,KAAK,EAAI;EAC/C,wBACEiB,+BAAC,aAAD,EAAmBM,kBAAnB,eACEN,+BAAC,SAAD,EAAejB,KAAf,CADF,CADF;EAKD,GAND,CADwB;;;EAUxB,MAAMyB,IAAI,GAAGJ,SAAS,CAACK,WAAV,IAAyBL,SAAS,CAACI,IAAnC,IAA2C,SAAxD;EACAD,EAAAA,OAAO,CAACE,WAAR,0BAA2CD,IAA3C;EAEA,SAAOD,OAAP;EACD;;EAED,SAASG,eAAT,CACEC,UADF,EAEkD;EAChD,wBAA0BX,gBAAK,CAACY,QAAN,CAAyB,IAAzB,CAA1B;EAAA,MAAOnC,KAAP;EAAA,MAAcoC,QAAd;;EACA,MAAIF,UAAJ,EAAgB,MAAMA,UAAN;EAChB,MAAIlC,KAAJ,EAAW,MAAMA,KAAN;EACX,SAAOoC,QAAP;EACD;EAWD;EACA;EACA;EACA;EACA;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"react-error-boundary.umd.js","sources":["../node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","../src/index.tsx"],"sourcesContent":["export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}","import * as React from 'react'\n\nconst changedArray = (a: Array<unknown> = [], b: Array<unknown> = []) =>\n a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]))\n\ninterface FallbackProps {\n error: Error\n resetErrorBoundary: (...args: Array<unknown>) => void\n}\n\ninterface ErrorBoundaryPropsWithComponent {\n onResetKeysChange?: (\n prevResetKeys: Array<unknown> | undefined,\n resetKeys: Array<unknown> | undefined,\n ) => void\n onReset?: (...args: Array<unknown>) => void\n onError?: (error: Error, info: {componentStack: string}) => void\n resetKeys?: Array<unknown>\n fallback?: never\n FallbackComponent: React.ComponentType<FallbackProps>\n fallbackRender?: never\n}\n\ndeclare function FallbackRender(\n props: FallbackProps,\n): React.ReactElement<\n unknown,\n string | React.FunctionComponent | typeof React.Component\n> | null\n\ninterface ErrorBoundaryPropsWithRender {\n onResetKeysChange?: (\n prevResetKeys: Array<unknown> | undefined,\n resetKeys: Array<unknown> | undefined,\n ) => void\n onReset?: (...args: Array<unknown>) => void\n onError?: (error: Error, info: {componentStack: string}) => void\n resetKeys?: Array<unknown>\n fallback?: never\n FallbackComponent?: never\n fallbackRender: typeof FallbackRender\n}\n\ninterface ErrorBoundaryPropsWithFallback {\n onResetKeysChange?: (\n prevResetKeys: Array<unknown> | undefined,\n resetKeys: Array<unknown> | undefined,\n ) => void\n onReset?: (...args: Array<unknown>) => void\n onError?: (error: Error, info: {componentStack: string}) => void\n resetKeys?: Array<unknown>\n fallback: React.ReactElement<\n unknown,\n string | React.FunctionComponent | typeof React.Component\n > | null\n FallbackComponent?: never\n fallbackRender?: never\n}\n\ntype ErrorBoundaryProps =\n | ErrorBoundaryPropsWithFallback\n | ErrorBoundaryPropsWithComponent\n | ErrorBoundaryPropsWithRender\n\ntype ErrorBoundaryState = {error: Error | null}\n\nconst initialState: ErrorBoundaryState = {error: null}\n\nclass ErrorBoundary extends React.Component<\n React.PropsWithRef<React.PropsWithChildren<ErrorBoundaryProps>>,\n ErrorBoundaryState\n> {\n static getDerivedStateFromError(error: Error) {\n return {error}\n }\n\n state = initialState\n updatedWithError = false\n resetErrorBoundary = (...args: Array<unknown>) => {\n this.props.onReset?.(...args)\n this.reset()\n }\n\n reset() {\n this.updatedWithError = false\n this.setState(initialState)\n }\n\n componentDidCatch(error: Error, info: React.ErrorInfo) {\n this.props.onError?.(error, info)\n }\n\n componentDidMount() {\n const {error} = this.state\n\n if (error !== null) {\n this.updatedWithError = true\n }\n }\n\n componentDidUpdate(prevProps: ErrorBoundaryProps) {\n const {error} = this.state\n const {resetKeys} = this.props\n\n // There's an edge case where if the thing that triggered the error\n // happens to *also* be in the resetKeys array, we'd end up resetting\n // the error boundary immediately. This would likely trigger a second\n // error to be thrown.\n // So we make sure that we don't check the resetKeys on the first call\n // of cDU after the error is set\n if (error !== null && !this.updatedWithError) {\n this.updatedWithError = true\n return\n }\n\n if (error !== null && changedArray(prevProps.resetKeys, resetKeys)) {\n this.props.onResetKeysChange?.(prevProps.resetKeys, resetKeys)\n this.reset()\n }\n }\n\n render() {\n const {error} = this.state\n\n const {fallbackRender, FallbackComponent, fallback} = this.props\n\n if (error !== null) {\n const props = {\n error,\n resetErrorBoundary: this.resetErrorBoundary,\n }\n if (React.isValidElement(fallback)) {\n return fallback\n } else if (typeof fallbackRender === 'function') {\n return fallbackRender(props)\n } else if (FallbackComponent) {\n return <FallbackComponent {...props} />\n } else {\n throw new Error(\n 'react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop',\n )\n }\n }\n\n return this.props.children\n }\n}\n\nfunction withErrorBoundary<P>(\n Component: React.ComponentType<P>,\n errorBoundaryProps: ErrorBoundaryProps,\n): React.ComponentType<P> {\n const Wrapped: React.ComponentType<P> = props => {\n return (\n <ErrorBoundary {...errorBoundaryProps}>\n <Component {...props} />\n </ErrorBoundary>\n )\n }\n\n // Format for display in DevTools\n const name = Component.displayName || Component.name || 'Unknown'\n Wrapped.displayName = `withErrorBoundary(${name})`\n\n return Wrapped\n}\n\nfunction useErrorHandler(givenError?: unknown): (error: unknown) => void {\n const [error, setError] = React.useState<unknown>(null)\n if (givenError != null) throw givenError\n if (error != null) throw error\n return setError\n}\n\nexport {ErrorBoundary, withErrorBoundary, useErrorHandler}\nexport type {\n FallbackProps,\n ErrorBoundaryPropsWithComponent,\n ErrorBoundaryPropsWithRender,\n ErrorBoundaryPropsWithFallback,\n ErrorBoundaryProps,\n}\n\n/*\neslint\n @typescript-eslint/no-throw-literal: \"off\",\n @typescript-eslint/prefer-nullish-coalescing: \"off\"\n*/\n"],"names":["_setPrototypeOf","o","p","Object","setPrototypeOf","__proto__","_inheritsLoose","subClass","superClass","prototype","create","constructor","changedArray","a","b","length","some","item","index","is","initialState","error","ErrorBoundary","state","updatedWithError","resetErrorBoundary","args","props","onReset","reset","getDerivedStateFromError","setState","componentDidCatch","info","onError","componentDidMount","componentDidUpdate","prevProps","resetKeys","onResetKeysChange","render","fallbackRender","FallbackComponent","fallback","React","isValidElement","Error","children","Component","withErrorBoundary","errorBoundaryProps","Wrapped","name","displayName","useErrorHandler","givenError","useState","setError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAe,SAASA,eAAT,CAAyBC,CAAzB,EAA4BC,CAA5B,EAA+B;EAC5CF,EAAAA,eAAe,GAAGG,MAAM,CAACC,cAAP,IAAyB,SAASJ,eAAT,CAAyBC,CAAzB,EAA4BC,CAA5B,EAA+B;EACxED,IAAAA,CAAC,CAACI,SAAF,GAAcH,CAAd;EACA,WAAOD,CAAP;EACD,GAHD;;EAKA,SAAOD,eAAe,CAACC,CAAD,EAAIC,CAAJ,CAAtB;EACD;;ECNc,SAASI,cAAT,CAAwBC,QAAxB,EAAkCC,UAAlC,EAA8C;EAC3DD,EAAAA,QAAQ,CAACE,SAAT,GAAqBN,MAAM,CAACO,MAAP,CAAcF,UAAU,CAACC,SAAzB,CAArB;EACAF,EAAAA,QAAQ,CAACE,SAAT,CAAmBE,WAAnB,GAAiCJ,QAAjC;EACAH,EAAAA,eAAc,CAACG,QAAD,EAAWC,UAAX,CAAd;EACD;;ECHD,IAAMI,YAAY,GAAG,SAAfA,YAAe,CAACC,CAAD,EAAyBC,CAAzB;EAAA,MAACD,CAAD;EAACA,IAAAA,CAAD,GAAqB,EAArB;EAAA;;EAAA,MAAyBC,CAAzB;EAAyBA,IAAAA,CAAzB,GAA6C,EAA7C;EAAA;;EAAA,SACnBD,CAAC,CAACE,MAAF,KAAaD,CAAC,CAACC,MAAf,IAAyBF,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;;;EAUxB,MAAMyB,IAAI,GAAGJ,SAAS,CAACK,WAAV,IAAyBL,SAAS,CAACI,IAAnC,IAA2C,SAAxD;EACAD,EAAAA,OAAO,CAACE,WAAR,0BAA2CD,IAA3C;EAEA,SAAOD,OAAP;EACD;;EAED,SAASG,eAAT,CAAyBC,UAAzB,EAAyE;EACvE,wBAA0BX,gBAAK,CAACY,QAAN,CAAwB,IAAxB,CAA1B;EAAA,MAAOnC,KAAP;EAAA,MAAcoC,QAAd;;EACA,MAAIF,UAAU,IAAI,IAAlB,EAAwB,MAAMA,UAAN;EACxB,MAAIlC,KAAK,IAAI,IAAb,EAAmB,MAAMA,KAAN;EACnB,SAAOoC,QAAP;EACD;EAWD;EACA;EACA;EACA;EACA;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!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})}));
|
|
1
|
+
!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})}));
|
|
2
2
|
//# sourceMappingURL=react-error-boundary.umd.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-error-boundary.umd.min.js","sources":["../node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","../src/index.tsx","../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js"],"sourcesContent":["export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}","import * as React from 'react'\n\nconst changedArray = (a: Array<unknown> = [], b: Array<unknown> = []) =>\n a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]))\n\ninterface FallbackProps {\n error: Error\n resetErrorBoundary: (...args: Array<unknown>) => void\n}\n\ninterface ErrorBoundaryPropsWithComponent {\n onResetKeysChange?: (\n prevResetKeys: Array<unknown> | undefined,\n resetKeys: Array<unknown> | undefined,\n ) => void\n onReset?: (...args: Array<unknown>) => void\n onError?: (error: Error, info: {componentStack: string}) => void\n resetKeys?: Array<unknown>\n fallback?: never\n FallbackComponent: React.ComponentType<FallbackProps>\n fallbackRender?: never\n}\n\ndeclare function FallbackRender(\n props: FallbackProps,\n): React.ReactElement<\n unknown,\n string | React.FunctionComponent | typeof React.Component\n> | null\n\ninterface ErrorBoundaryPropsWithRender {\n onResetKeysChange?: (\n prevResetKeys: Array<unknown> | undefined,\n resetKeys: Array<unknown> | undefined,\n ) => void\n onReset?: (...args: Array<unknown>) => void\n onError?: (error: Error, info: {componentStack: string}) => void\n resetKeys?: Array<unknown>\n fallback?: never\n FallbackComponent?: never\n fallbackRender: typeof FallbackRender\n}\n\ninterface ErrorBoundaryPropsWithFallback {\n onResetKeysChange?: (\n prevResetKeys: Array<unknown> | undefined,\n resetKeys: Array<unknown> | undefined,\n ) => void\n onReset?: (...args: Array<unknown>) => void\n onError?: (error: Error, info: {componentStack: string}) => void\n resetKeys?: Array<unknown>\n fallback: React.ReactElement<\n unknown,\n string | React.FunctionComponent | typeof React.Component\n > | null\n FallbackComponent?: never\n fallbackRender?: never\n}\n\ntype ErrorBoundaryProps =\n | ErrorBoundaryPropsWithFallback\n | ErrorBoundaryPropsWithComponent\n | ErrorBoundaryPropsWithRender\n\ntype ErrorBoundaryState = {error: Error | null}\n\nconst initialState: ErrorBoundaryState = {error: null}\n\nclass ErrorBoundary extends React.Component<\n React.PropsWithRef<React.PropsWithChildren<ErrorBoundaryProps>>,\n ErrorBoundaryState\n> {\n static getDerivedStateFromError(error: Error) {\n return {error}\n }\n\n state = initialState\n updatedWithError = false\n resetErrorBoundary = (...args: Array<unknown>) => {\n this.props.onReset?.(...args)\n this.reset()\n }\n\n reset() {\n this.updatedWithError = false\n this.setState(initialState)\n }\n\n componentDidCatch(error: Error, info: React.ErrorInfo) {\n this.props.onError?.(error, info)\n }\n\n componentDidMount() {\n const {error} = this.state\n\n if (error !== null) {\n this.updatedWithError = true\n }\n }\n\n componentDidUpdate(prevProps: ErrorBoundaryProps) {\n const {error} = this.state\n const {resetKeys} = this.props\n\n // There's an edge case where if the thing that triggered the error\n // happens to *also* be in the resetKeys array, we'd end up resetting\n // the error boundary immediately. This would likely trigger a second\n // error to be thrown.\n // So we make sure that we don't check the resetKeys on the first call\n // of cDU after the error is set\n if (error !== null && !this.updatedWithError) {\n this.updatedWithError = true\n return\n }\n\n if (error !== null && changedArray(prevProps.resetKeys, resetKeys)) {\n this.props.onResetKeysChange?.(prevProps.resetKeys, resetKeys)\n this.reset()\n }\n }\n\n render() {\n const {error} = this.state\n\n const {fallbackRender, FallbackComponent, fallback} = this.props\n\n if (error !== null) {\n const props = {\n error,\n resetErrorBoundary: this.resetErrorBoundary,\n }\n if (React.isValidElement(fallback)) {\n return fallback\n } else if (typeof fallbackRender === 'function') {\n return fallbackRender(props)\n } else if (FallbackComponent) {\n return <FallbackComponent {...props} />\n } else {\n throw new Error(\n 'react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop',\n )\n }\n }\n\n return this.props.children\n }\n}\n\nfunction withErrorBoundary<P>(\n Component: React.ComponentType<P>,\n errorBoundaryProps: ErrorBoundaryProps,\n): React.ComponentType<P> {\n const Wrapped: React.ComponentType<P> = props => {\n return (\n <ErrorBoundary {...errorBoundaryProps}>\n <Component {...props} />\n </ErrorBoundary>\n )\n }\n\n // Format for display in DevTools\n const name = Component.displayName || Component.name || 'Unknown'\n Wrapped.displayName = `withErrorBoundary(${name})`\n\n return Wrapped\n}\n\nfunction useErrorHandler
|
|
1
|
+
{"version":3,"file":"react-error-boundary.umd.min.js","sources":["../node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","../src/index.tsx","../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js"],"sourcesContent":["export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}","import * as React from 'react'\n\nconst changedArray = (a: Array<unknown> = [], b: Array<unknown> = []) =>\n a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]))\n\ninterface FallbackProps {\n error: Error\n resetErrorBoundary: (...args: Array<unknown>) => void\n}\n\ninterface ErrorBoundaryPropsWithComponent {\n onResetKeysChange?: (\n prevResetKeys: Array<unknown> | undefined,\n resetKeys: Array<unknown> | undefined,\n ) => void\n onReset?: (...args: Array<unknown>) => void\n onError?: (error: Error, info: {componentStack: string}) => void\n resetKeys?: Array<unknown>\n fallback?: never\n FallbackComponent: React.ComponentType<FallbackProps>\n fallbackRender?: never\n}\n\ndeclare function FallbackRender(\n props: FallbackProps,\n): React.ReactElement<\n unknown,\n string | React.FunctionComponent | typeof React.Component\n> | null\n\ninterface ErrorBoundaryPropsWithRender {\n onResetKeysChange?: (\n prevResetKeys: Array<unknown> | undefined,\n resetKeys: Array<unknown> | undefined,\n ) => void\n onReset?: (...args: Array<unknown>) => void\n onError?: (error: Error, info: {componentStack: string}) => void\n resetKeys?: Array<unknown>\n fallback?: never\n FallbackComponent?: never\n fallbackRender: typeof FallbackRender\n}\n\ninterface ErrorBoundaryPropsWithFallback {\n onResetKeysChange?: (\n prevResetKeys: Array<unknown> | undefined,\n resetKeys: Array<unknown> | undefined,\n ) => void\n onReset?: (...args: Array<unknown>) => void\n onError?: (error: Error, info: {componentStack: string}) => void\n resetKeys?: Array<unknown>\n fallback: React.ReactElement<\n unknown,\n string | React.FunctionComponent | typeof React.Component\n > | null\n FallbackComponent?: never\n fallbackRender?: never\n}\n\ntype ErrorBoundaryProps =\n | ErrorBoundaryPropsWithFallback\n | ErrorBoundaryPropsWithComponent\n | ErrorBoundaryPropsWithRender\n\ntype ErrorBoundaryState = {error: Error | null}\n\nconst initialState: ErrorBoundaryState = {error: null}\n\nclass ErrorBoundary extends React.Component<\n React.PropsWithRef<React.PropsWithChildren<ErrorBoundaryProps>>,\n ErrorBoundaryState\n> {\n static getDerivedStateFromError(error: Error) {\n return {error}\n }\n\n state = initialState\n updatedWithError = false\n resetErrorBoundary = (...args: Array<unknown>) => {\n this.props.onReset?.(...args)\n this.reset()\n }\n\n reset() {\n this.updatedWithError = false\n this.setState(initialState)\n }\n\n componentDidCatch(error: Error, info: React.ErrorInfo) {\n this.props.onError?.(error, info)\n }\n\n componentDidMount() {\n const {error} = this.state\n\n if (error !== null) {\n this.updatedWithError = true\n }\n }\n\n componentDidUpdate(prevProps: ErrorBoundaryProps) {\n const {error} = this.state\n const {resetKeys} = this.props\n\n // There's an edge case where if the thing that triggered the error\n // happens to *also* be in the resetKeys array, we'd end up resetting\n // the error boundary immediately. This would likely trigger a second\n // error to be thrown.\n // So we make sure that we don't check the resetKeys on the first call\n // of cDU after the error is set\n if (error !== null && !this.updatedWithError) {\n this.updatedWithError = true\n return\n }\n\n if (error !== null && changedArray(prevProps.resetKeys, resetKeys)) {\n this.props.onResetKeysChange?.(prevProps.resetKeys, resetKeys)\n this.reset()\n }\n }\n\n render() {\n const {error} = this.state\n\n const {fallbackRender, FallbackComponent, fallback} = this.props\n\n if (error !== null) {\n const props = {\n error,\n resetErrorBoundary: this.resetErrorBoundary,\n }\n if (React.isValidElement(fallback)) {\n return fallback\n } else if (typeof fallbackRender === 'function') {\n return fallbackRender(props)\n } else if (FallbackComponent) {\n return <FallbackComponent {...props} />\n } else {\n throw new Error(\n 'react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop',\n )\n }\n }\n\n return this.props.children\n }\n}\n\nfunction withErrorBoundary<P>(\n Component: React.ComponentType<P>,\n errorBoundaryProps: ErrorBoundaryProps,\n): React.ComponentType<P> {\n const Wrapped: React.ComponentType<P> = props => {\n return (\n <ErrorBoundary {...errorBoundaryProps}>\n <Component {...props} />\n </ErrorBoundary>\n )\n }\n\n // Format for display in DevTools\n const name = Component.displayName || Component.name || 'Unknown'\n Wrapped.displayName = `withErrorBoundary(${name})`\n\n return Wrapped\n}\n\nfunction useErrorHandler(givenError?: unknown): (error: unknown) => void {\n const [error, setError] = React.useState<unknown>(null)\n if (givenError != null) throw givenError\n if (error != null) throw error\n return setError\n}\n\nexport {ErrorBoundary, withErrorBoundary, useErrorHandler}\nexport type {\n FallbackProps,\n ErrorBoundaryPropsWithComponent,\n ErrorBoundaryPropsWithRender,\n ErrorBoundaryPropsWithFallback,\n ErrorBoundaryProps,\n}\n\n/*\neslint\n @typescript-eslint/no-throw-literal: \"off\",\n @typescript-eslint/prefer-nullish-coalescing: \"off\"\n*/\n","import setPrototypeOf from \"./setPrototypeOf.js\";\nexport default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n setPrototypeOf(subClass, superClass);\n}"],"names":["_setPrototypeOf","o","p","Object","setPrototypeOf","__proto__","initialState","error","ErrorBoundary","subClass","superClass","state","updatedWithError","resetErrorBoundary","args","props","onReset","reset","prototype","create","constructor","getDerivedStateFromError","setState","componentDidCatch","info","onError","componentDidMount","this","componentDidUpdate","prevProps","a","b","resetKeys","length","some","item","index","is","onResetKeysChange","render","fallbackRender","FallbackComponent","fallback","React","isValidElement","Error","children","Component","givenError","useState","setError","errorBoundaryProps","Wrapped","name","displayName"],"mappings":"ukBAA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