react-error-boundary 3.1.0 → 3.1.1
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/dist/index.d.ts +1 -0
- package/dist/react-error-boundary.cjs.d.ts +1 -1
- package/dist/react-error-boundary.cjs.js +11 -3
- package/dist/react-error-boundary.esm.d.ts +1 -1
- package/dist/react-error-boundary.esm.js +11 -3
- package/dist/react-error-boundary.umd.d.ts +1 -1
- package/dist/react-error-boundary.umd.js +21 -4
- package/dist/react-error-boundary.umd.js.map +1 -1
- package/dist/react-error-boundary.umd.min.d.ts +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/dist/index.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ declare class ErrorBoundary extends React.Component<React.PropsWithRef<React.Pro
|
|
|
44
44
|
resetErrorBoundary: (...args: Array<unknown>) => void;
|
|
45
45
|
reset(): void;
|
|
46
46
|
componentDidCatch(error: Error, info: React.ErrorInfo): void;
|
|
47
|
+
componentDidMount(): void;
|
|
47
48
|
componentDidUpdate(prevProps: ErrorBoundaryProps): void;
|
|
48
49
|
render(): {} | null | undefined;
|
|
49
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "
|
|
1
|
+
export * from "../dist/index";
|
|
@@ -9,7 +9,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
9
|
|
|
10
10
|
var _inheritsLoose__default = /*#__PURE__*/_interopDefaultLegacy(_inheritsLoose);
|
|
11
11
|
|
|
12
|
-
var changedArray = function (a, b) {
|
|
12
|
+
var changedArray = function changedArray(a, b) {
|
|
13
13
|
if (a === void 0) {
|
|
14
14
|
a = [];
|
|
15
15
|
}
|
|
@@ -75,6 +75,14 @@ var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
|
75
75
|
(_this$props$onError = (_this$props2 = this.props).onError) == null ? void 0 : _this$props$onError.call(_this$props2, error, info);
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
79
|
+
var error = this.state.error;
|
|
80
|
+
|
|
81
|
+
if (error !== null) {
|
|
82
|
+
this.updatedWithError = true;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
78
86
|
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
|
|
79
87
|
var error = this.state.error;
|
|
80
88
|
var resetKeys = this.props.resetKeys; // There's an edge case where if the thing that triggered the error
|
|
@@ -98,7 +106,7 @@ var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
|
98
106
|
};
|
|
99
107
|
|
|
100
108
|
_proto.render = function render() {
|
|
101
|
-
var error = this.state.error; // @ts-expect-error ts(2339) (at least one of these will be defined though, and we check for their
|
|
109
|
+
var error = this.state.error; // @ts-expect-error ts(2339) (at least one of these will be defined though, and we check for their existence)
|
|
102
110
|
|
|
103
111
|
var _this$props4 = this.props,
|
|
104
112
|
fallbackRender = _this$props4.fallbackRender,
|
|
@@ -129,7 +137,7 @@ var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
|
129
137
|
}(React.Component);
|
|
130
138
|
|
|
131
139
|
function withErrorBoundary(Component, errorBoundaryProps) {
|
|
132
|
-
var Wrapped = function (props) {
|
|
140
|
+
var Wrapped = function Wrapped(props) {
|
|
133
141
|
return /*#__PURE__*/React.createElement(ErrorBoundary, errorBoundaryProps, /*#__PURE__*/React.createElement(Component, props));
|
|
134
142
|
}; // Format for display in DevTools
|
|
135
143
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "
|
|
1
|
+
export * from "../dist/index";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
|
|
2
2
|
import { isValidElement, createElement, Component, useState } from 'react';
|
|
3
3
|
|
|
4
|
-
var changedArray = function (a, b) {
|
|
4
|
+
var changedArray = function changedArray(a, b) {
|
|
5
5
|
if (a === void 0) {
|
|
6
6
|
a = [];
|
|
7
7
|
}
|
|
@@ -67,6 +67,14 @@ var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
|
67
67
|
(_this$props$onError = (_this$props2 = this.props).onError) == null ? void 0 : _this$props$onError.call(_this$props2, error, info);
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
71
|
+
var error = this.state.error;
|
|
72
|
+
|
|
73
|
+
if (error !== null) {
|
|
74
|
+
this.updatedWithError = true;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
70
78
|
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
|
|
71
79
|
var error = this.state.error;
|
|
72
80
|
var resetKeys = this.props.resetKeys; // There's an edge case where if the thing that triggered the error
|
|
@@ -90,7 +98,7 @@ var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
|
90
98
|
};
|
|
91
99
|
|
|
92
100
|
_proto.render = function render() {
|
|
93
|
-
var error = this.state.error; // @ts-expect-error ts(2339) (at least one of these will be defined though, and we check for their
|
|
101
|
+
var error = this.state.error; // @ts-expect-error ts(2339) (at least one of these will be defined though, and we check for their existence)
|
|
94
102
|
|
|
95
103
|
var _this$props4 = this.props,
|
|
96
104
|
fallbackRender = _this$props4.fallbackRender,
|
|
@@ -121,7 +129,7 @@ var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
|
121
129
|
}(Component);
|
|
122
130
|
|
|
123
131
|
function withErrorBoundary(Component, errorBoundaryProps) {
|
|
124
|
-
var Wrapped = function (props) {
|
|
132
|
+
var Wrapped = function Wrapped(props) {
|
|
125
133
|
return /*#__PURE__*/createElement(ErrorBoundary, errorBoundaryProps, /*#__PURE__*/createElement(Component, props));
|
|
126
134
|
}; // Format for display in DevTools
|
|
127
135
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "
|
|
1
|
+
export * from "../dist/index";
|
|
@@ -4,13 +4,22 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactErrorBoundary = {}, global.React));
|
|
5
5
|
}(this, (function (exports, React) { 'use strict';
|
|
6
6
|
|
|
7
|
+
function _setPrototypeOf(o, p) {
|
|
8
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
9
|
+
o.__proto__ = p;
|
|
10
|
+
return o;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
return _setPrototypeOf(o, p);
|
|
14
|
+
}
|
|
15
|
+
|
|
7
16
|
function _inheritsLoose(subClass, superClass) {
|
|
8
17
|
subClass.prototype = Object.create(superClass.prototype);
|
|
9
18
|
subClass.prototype.constructor = subClass;
|
|
10
|
-
subClass
|
|
19
|
+
_setPrototypeOf(subClass, superClass);
|
|
11
20
|
}
|
|
12
21
|
|
|
13
|
-
var changedArray = function (a, b) {
|
|
22
|
+
var changedArray = function changedArray(a, b) {
|
|
14
23
|
if (a === void 0) {
|
|
15
24
|
a = [];
|
|
16
25
|
}
|
|
@@ -76,6 +85,14 @@
|
|
|
76
85
|
(_this$props$onError = (_this$props2 = this.props).onError) == null ? void 0 : _this$props$onError.call(_this$props2, error, info);
|
|
77
86
|
};
|
|
78
87
|
|
|
88
|
+
_proto.componentDidMount = function componentDidMount() {
|
|
89
|
+
var error = this.state.error;
|
|
90
|
+
|
|
91
|
+
if (error !== null) {
|
|
92
|
+
this.updatedWithError = true;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
79
96
|
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
|
|
80
97
|
var error = this.state.error;
|
|
81
98
|
var resetKeys = this.props.resetKeys; // There's an edge case where if the thing that triggered the error
|
|
@@ -99,7 +116,7 @@
|
|
|
99
116
|
};
|
|
100
117
|
|
|
101
118
|
_proto.render = function render() {
|
|
102
|
-
var error = this.state.error; // @ts-expect-error ts(2339) (at least one of these will be defined though, and we check for their
|
|
119
|
+
var error = this.state.error; // @ts-expect-error ts(2339) (at least one of these will be defined though, and we check for their existence)
|
|
103
120
|
|
|
104
121
|
var _this$props4 = this.props,
|
|
105
122
|
fallbackRender = _this$props4.fallbackRender,
|
|
@@ -130,7 +147,7 @@
|
|
|
130
147
|
}(React.Component);
|
|
131
148
|
|
|
132
149
|
function withErrorBoundary(Component, errorBoundaryProps) {
|
|
133
|
-
var Wrapped = function (props) {
|
|
150
|
+
var Wrapped = function Wrapped(props) {
|
|
134
151
|
return /*#__PURE__*/React.createElement(ErrorBoundary, errorBoundaryProps, /*#__PURE__*/React.createElement(Component, props));
|
|
135
152
|
}; // Format for display in DevTools
|
|
136
153
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-error-boundary.umd.js","sources":["../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js","../src/index.tsx"],"sourcesContent":["export default function _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n subClass.__proto__ = 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 FallbackComponent: React.ComponentType<FallbackProps>\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 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}\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 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 // @ts-expect-error ts(2339) (at least one of these will be defined though, and we check for their existance)\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 as typeof 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":["_inheritsLoose","subClass","superClass","prototype","Object","create","constructor","__proto__","changedArray","a","b","length","some","item","index","is","initialState","error","ErrorBoundary","state","updatedWithError","resetErrorBoundary","args","props","onReset","reset","getDerivedStateFromError","setState","componentDidCatch","info","onError","componentDidUpdate","prevProps","resetKeys","onResetKeysChange","render","fallbackRender","FallbackComponent","fallback","React","React.createElement","Error","children","withErrorBoundary","Component","errorBoundaryProps","Wrapped","name","displayName","useErrorHandler","givenError","setError"],"mappings":";;;;;;EAAe,SAASA,cAAT,CAAwBC,QAA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;EAGD;EACF;;EAED,WAAO,KAAKlB,KAAL,CAAWmB,QAAlB;EACD;;;IArEyBH;;EAwE5B,SAASI,iBAAT,CACEC,SADF,EAEEC,kBAFF,EAG0B;EACxB,MAAMC,OAA+B,GAAG,UAAAvB,KAAK,EAAI;EAC/C,wBACEiB,oBAAC,aAAD,EAAmBK,kBAAnB,eACEL,oBAAC,SAAD,EAAejB,KAAf,CADF,CADF;EAKD,GAND,CADwB;;;EAUxB,MAAMwB,IAAI,GAAGH,SAAS,CAACI,WAAV,IAAyBJ,SAAS,CAACG,IAAnC,IAA2C,SAAxD;EACAD,EAAAA,OAAO,CAACE,WAAR,0BAA2CD,IAA3C;EAEA,SAAOD,OAAP;EACD;;EAED,SAASG,eAAT,CACEC,UADF,EAEkD;EAAA,wBACtBX,cAAA,CAAyB,IAAzB,CADsB;EAAA,MACzCtB,KADyC;EAAA,MAClCkC,QADkC;;EAEhD,MAAID,UAAJ,EAAgB,MAAMA,UAAN;EAChB,MAAIjC,KAAJ,EAAW,MAAMA,KAAN;EACX,SAAOkC,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 FallbackComponent: React.ComponentType<FallbackProps>\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 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}\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 // @ts-expect-error ts(2339) (at least one of these will be defined though, and we check for their existence)\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 as typeof 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","React.createElement","Error","children","withErrorBoundary","Component","errorBoundaryProps","Wrapped","name","displayName","useErrorHandler","givenError","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,MA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oBAAC,aAAD,EAAmBK,kBAAnB,eACEL,oBAAC,SAAD,EAAelB,KAAf,CADF,CADF;EAKD,GAND,CADwB;;;EAUxB,MAAMyB,IAAI,GAAGH,SAAS,CAACI,WAAV,IAAyBJ,SAAS,CAACG,IAAnC,IAA2C,SAAxD;EACAD,EAAAA,OAAO,CAACE,WAAR,0BAA2CD,IAA3C;EAEA,SAAOD,OAAP;EACD;;EAED,SAASG,eAAT,CACEC,UADF,EAEkD;EAAA,wBACtBX,cAAA,CAAyB,IAAzB,CADsB;EAAA,MACzCvB,KADyC;EAAA,MAClCmC,QADkC;;EAEhD,MAAID,UAAJ,EAAgB,MAAMA,UAAN;EAChB,MAAIlC,KAAJ,EAAW,MAAMA,KAAN;EACX,SAAOmC,QAAP;EACD;EAWD;EACA;EACA;EACA;EACA;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "
|
|
1
|
+
export * from "../dist/index";
|
|
@@ -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";
|
|
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,e){return(t=Object.setPrototypeOf||function(r,e){return r.__proto__=e,r})(r,e)}var n={error:null},o=function(r){var o,a;function i(){for(var e,t=arguments.length,o=new Array(t),a=0;a<t;a++)o[a]=arguments[a];return(e=r.call.apply(r,[this].concat(o))||this).state=n,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}a=r,(o=i).prototype=Object.create(a.prototype),o.prototype.constructor=o,t(o,a),i.getDerivedStateFromError=function(r){return{error:r}};var u=i.prototype;return u.reset=function(){this.updatedWithError=!1,this.setState(n)},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,t=this.props,n=t.fallbackRender,o=t.FallbackComponent,a=t.fallback;if(null!==r){var i={error:r,resetErrorBoundary:this.resetErrorBoundary};if(e.isValidElement(a))return a;if("function"==typeof n)return n(i);if(o)return e.createElement(o,i);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},i}(e.Component);r.ErrorBoundary=o,r.useErrorHandler=function(r){var t=e.useState(null),n=t[0],o=t[1];if(r)throw r;if(n)throw n;return o},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})}));
|
|
2
2
|
//# sourceMappingURL=react-error-boundary.umd.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-error-boundary.umd.min.js","sources":["../src/index.tsx","../node_modules/@babel/runtime/helpers/esm/inheritsLoose.js"],"sourcesContent":["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 FallbackComponent: React.ComponentType<FallbackProps>\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 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}\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 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 // @ts-expect-error ts(2339) (at least one of these will be defined though, and we check for their
|
|
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 FallbackComponent: React.ComponentType<FallbackProps>\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 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}\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 // @ts-expect-error ts(2339) (at least one of these will be defined though, and we check for their existence)\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 as typeof 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","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","React.createElement","Error","children","givenError","setError","Component","errorBoundaryProps","Wrapped","name","displayName"],"mappings":"6RAAe,SAASA,EAAgBC,EAAGC,UACzCF,EAAkBG,OAAOC,gBAAkB,SAAyBH,EAAGC,UACrED,EAAEI,UAAYH,EACPD,IAGcA,EAAGC,GCJ5B,IA0DMI,EAAmC,CAACC,MAAO,MAE3CC,cC7DS,IAAwBC,EAAUC,0IDqE/CC,MAAQL,IACRM,kBAAmB,IACnBC,mBAAqB,wCAAIC,2BAAAA,0BAClBC,MAAMC,cAAND,OAAMC,gBAAaF,KACnBG,WCzEwCP,KAAVD,KAC5BS,UAAYf,OAAOgB,OAAOT,EAAWQ,WAC9CT,EAASS,UAAUE,YAAcX,EACjCL,EAAeK,EAAUC,KD8DlBW,yBAAP,SAAgCd,SACvB,CAACA,MAAAA,+BAUVU,MAAA,gBACOL,kBAAmB,OACnBU,SAAShB,MAGhBiB,kBAAA,SAAkBhB,EAAciB,4BACzBT,OAAMU,mBAAUlB,EAAOiB,MAG9BE,kBAAA,WAGgB,OAFEC,KAAKhB,MAAdJ,aAGAK,kBAAmB,MAI5BgB,mBAAA,SAAmBC,WA5FCC,EAAwBC,EA6FnCxB,EAASoB,KAAKhB,MAAdJ,MACAyB,EAAaL,KAAKZ,MAAlBiB,UAQO,OAAVzB,GAAmBoB,KAAKf,iBAKd,OAAVL,cA3GcuB,EA2GiBD,EAAUG,aA3G3BF,EAAoB,cAAIC,EA2GcC,KA3GdD,EAAoB,IAChED,EAAEG,SAAWF,EAAEE,QAAUH,EAAEI,MAAK,SAACC,EAAMC,UAAWjC,OAAOkC,GAAGF,EAAMJ,EAAEK,2BA2G3DrB,OAAMuB,6BAAoBT,EAAUG,UAAWA,QAC/Cf,cANAL,kBAAmB,KAU5B2B,OAAA,eACShC,EAASoB,KAAKhB,MAAdJ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