react-error-boundary 6.0.2 → 6.1.0
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
CHANGED
|
@@ -63,7 +63,7 @@ None
|
|
|
63
63
|
<tr>
|
|
64
64
|
<td>onError</td>
|
|
65
65
|
<td><p>Optional callback to enable e.g. logging error information to a server.
|
|
66
|
-
@param error
|
|
66
|
+
@param error Value that was thrown; typically an instance of <code>Error</code>
|
|
67
67
|
@param info React "component stack" identifying where the error was thrown</p>
|
|
68
68
|
</td>
|
|
69
69
|
</tr>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),c=s.createContext(null),u={didCatch:!1,error:null};class
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),c=s.createContext(null),u={didCatch:!1,error:null};class y extends s.Component{constructor(e){super(e),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=u}static getDerivedStateFromError(e){return{didCatch:!0,error:e}}resetErrorBoundary(...e){const{error:t}=this.state;t!==null&&(this.props.onReset?.({args:e,reason:"imperative-api"}),this.setState(u))}componentDidCatch(e,t){this.props.onError?.(e,t)}componentDidUpdate(e,t){const{didCatch:o}=this.state,{resetKeys:n}=this.props;o&&t.error!==null&&h(e.resetKeys,n)&&(this.props.onReset?.({next:n,prev:e.resetKeys,reason:"keys"}),this.setState(u))}render(){const{children:e,fallbackRender:t,FallbackComponent:o,fallback:n}=this.props,{didCatch:a,error:i}=this.state;let d=e;if(a){const l={error:i,resetErrorBoundary:this.resetErrorBoundary};if(typeof t=="function")d=t(l);else if(o)d=s.createElement(o,l);else if(n!==void 0)d=n;else throw i}return s.createElement(c.Provider,{value:{didCatch:a,error:i,resetErrorBoundary:this.resetErrorBoundary}},d)}}function h(r=[],e=[]){return r.length!==e.length||r.some((t,o)=>!Object.is(t,e[o]))}function E(r){return r!==null&&typeof r=="object"&&"didCatch"in r&&typeof r.didCatch=="boolean"&&"error"in r&&"resetErrorBoundary"in r&&typeof r.resetErrorBoundary=="function"}function f(r){if(!E(r))throw new Error("ErrorBoundaryContext not found")}function p(){const r=s.useContext(c);f(r);const{error:e,resetErrorBoundary:t}=r,[o,n]=s.useState({error:null,hasError:!1}),a=s.useMemo(()=>({error:e,resetBoundary:()=>{t(),n({error:null,hasError:!1})},showBoundary:i=>n({error:i,hasError:!0})}),[e,t]);if(o.hasError)throw o.error;return a}function B(r){switch(typeof r){case"object":{if(r!==null&&"message"in r&&typeof r.message=="string")return r.message;break}case"string":return r}}function m(r,e){const t=s.forwardRef((n,a)=>s.createElement(y,e,s.createElement(r,{...n,ref:a}))),o=r.displayName||r.name||"Unknown";return t.displayName=`withErrorBoundary(${o})`,t}exports.ErrorBoundary=y;exports.ErrorBoundaryContext=c;exports.getErrorMessage=B;exports.useErrorBoundary=p;exports.withErrorBoundary=m;
|
|
2
2
|
//# sourceMappingURL=react-error-boundary.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-error-boundary.cjs","sources":["../lib/context/ErrorBoundaryContext.ts","../lib/components/ErrorBoundary.tsx","../lib/utils/isErrorBoundaryContext.ts","../lib/utils/assertErrorBoundaryContext.ts","../lib/hooks/useErrorBoundary.ts","../lib/utils/withErrorBoundary.ts"],"sourcesContent":["import { createContext } from \"react\";\n\nexport type ErrorBoundaryContextType = {\n didCatch: boolean;\n error: Error | null;\n resetErrorBoundary: (...args: unknown[]) => void;\n};\n\nexport const ErrorBoundaryContext =\n createContext<ErrorBoundaryContextType | null>(null);\n","import { Component, createElement, type ErrorInfo } from \"react\";\nimport { ErrorBoundaryContext } from \"../context/ErrorBoundaryContext\";\nimport type { ErrorBoundaryProps, FallbackProps } from \"../types\";\n\nconst isDevelopment = import.meta.env.DEV;\n\ntype ErrorBoundaryState =\n | {\n didCatch: true;\n error: Error;\n }\n | {\n didCatch: false;\n error: null;\n };\n\nconst initialState: ErrorBoundaryState = {\n didCatch: false,\n error: null,\n};\n\n/**\n * A reusable React [error boundary](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary) component.\n * Wrap this component around other React components to \"catch\" errors and render a fallback UI.\n *\n * This package is built on top of React [error boundaries](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary),\n * so it has all of the advantages and constraints of that API.\n * This means that it can't catch errors during:\n * - Server side rendering</li>\n * - Event handlers\n * - Asynchronous code (including effects)\n *\n * ℹ️ The component provides several ways to render a fallback: `fallback`, `fallbackRender`, and `FallbackComponent`.\n * Refer to the documentation to determine which is best for your application.\n *\n * ℹ️ This is a **client component**. You can only pass props to it that are serializeable or use it in files that have a `\"use client\";` directive.\n */\nexport class ErrorBoundary extends Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n\n this.resetErrorBoundary = this.resetErrorBoundary.bind(this);\n this.state = initialState;\n }\n\n static getDerivedStateFromError(error: Error) {\n return { didCatch: true, error };\n }\n\n resetErrorBoundary(...args: unknown[]) {\n const { error } = this.state;\n\n if (error !== null) {\n this.props.onReset?.({\n args,\n reason: \"imperative-api\",\n });\n\n this.setState(initialState);\n }\n }\n\n componentDidCatch(error: Error, info: ErrorInfo) {\n this.props.onError?.(error, info);\n }\n\n componentDidUpdate(\n prevProps: ErrorBoundaryProps,\n prevState: ErrorBoundaryState,\n ) {\n const { didCatch } = this.state;\n const { resetKeys } = this.props;\n\n // There's an edge case where if the thing that triggered the error happens to *also* be in the resetKeys array,\n // we'd end up resetting the error boundary immediately.\n // This would likely trigger a second error to be thrown.\n // So we make sure that we don't check the resetKeys on the first call of cDU after the error is set.\n\n if (\n didCatch &&\n prevState.error !== null &&\n hasArrayChanged(prevProps.resetKeys, resetKeys)\n ) {\n this.props.onReset?.({\n next: resetKeys,\n prev: prevProps.resetKeys,\n reason: \"keys\",\n });\n\n this.setState(initialState);\n }\n }\n\n render() {\n const { children, fallbackRender, FallbackComponent, fallback } =\n this.props;\n const { didCatch, error } = this.state;\n\n let childToRender = children;\n\n if (didCatch) {\n const props: FallbackProps = {\n error,\n resetErrorBoundary: this.resetErrorBoundary,\n };\n\n if (typeof fallbackRender === \"function\") {\n childToRender = fallbackRender(props);\n } else if (FallbackComponent) {\n childToRender = createElement(FallbackComponent, props);\n } else if (fallback !== undefined) {\n childToRender = fallback;\n } else {\n if (isDevelopment) {\n console.error(\n \"react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop\",\n );\n }\n\n throw error;\n }\n }\n\n return createElement(\n ErrorBoundaryContext.Provider,\n {\n value: {\n didCatch,\n error,\n resetErrorBoundary: this.resetErrorBoundary,\n },\n },\n childToRender,\n );\n }\n}\n\nfunction hasArrayChanged(a: unknown[] = [], b: unknown[] = []) {\n return (\n a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]))\n );\n}\n","import type { ErrorBoundaryContextType } from \"../context/ErrorBoundaryContext\";\n\nexport function isErrorBoundaryContext(\n value: unknown,\n): value is ErrorBoundaryContextType {\n return (\n value !== null &&\n typeof value === \"object\" &&\n \"didCatch\" in value &&\n typeof value.didCatch === \"boolean\" &&\n \"error\" in value &&\n \"resetErrorBoundary\" in value &&\n typeof value.resetErrorBoundary === \"function\"\n );\n}\n","import type { ErrorBoundaryContextType } from \"../context/ErrorBoundaryContext\";\nimport { isErrorBoundaryContext } from \"./isErrorBoundaryContext\";\n\nexport function assertErrorBoundaryContext(\n value: unknown,\n): asserts value is ErrorBoundaryContextType {\n if (!isErrorBoundaryContext(value)) {\n throw new Error(\"ErrorBoundaryContext not found\");\n }\n}\n","import { useContext, useMemo, useState } from \"react\";\nimport { ErrorBoundaryContext } from \"../context/ErrorBoundaryContext\";\nimport { assertErrorBoundaryContext } from \"../utils/assertErrorBoundaryContext\";\n\ntype UseErrorBoundaryState =\n | { error: Error; hasError: true }\n | { error: null; hasError: false };\n\nexport type UseErrorBoundaryApi = {\n error: Error | null;\n resetBoundary: () => void;\n showBoundary: (error: Error) => void;\n};\n\n/**\n * Convenience hook for imperatively showing or dismissing error boundaries.\n *\n * ⚠️ This hook must only be used within an `ErrorBoundary` subtree.\n */\nexport function useErrorBoundary(): {\n /**\n * The currently visible `Error` (if one has been thrown).\n */\n error: Error | null;\n\n /**\n * Method to reset and retry the nearest active error boundary (if one is active).\n */\n resetBoundary: () => void;\n\n /**\n * Trigger the nearest error boundary to display the error provided.\n *\n * ℹ️ React only handles errors thrown during render or during component lifecycle methods (e.g. effects and did-mount/did-update).\n * Errors thrown in event handlers, or after async code has run, will not be caught.\n * This method is a way to imperatively trigger an error boundary during these phases.\n */\n showBoundary: (error: Error) => void;\n} {\n const context = useContext(ErrorBoundaryContext);\n\n assertErrorBoundaryContext(context);\n\n const { error, resetErrorBoundary } = context;\n\n const [state, setState] = useState<UseErrorBoundaryState>({\n error: null,\n hasError: false,\n });\n\n const memoized = useMemo(\n () => ({\n error,\n resetBoundary: () => {\n resetErrorBoundary();\n setState({ error: null, hasError: false });\n },\n showBoundary: (error: Error) =>\n setState({\n error,\n hasError: true,\n }),\n }),\n [error, resetErrorBoundary],\n );\n\n if (state.hasError) {\n throw state.error;\n }\n\n return memoized;\n}\n","import {\n createElement,\n forwardRef,\n type ComponentClass,\n type ComponentType,\n} from \"react\";\nimport { ErrorBoundary } from \"../components/ErrorBoundary\";\nimport type { ErrorBoundaryProps } from \"../types\";\n\nexport function withErrorBoundary<\n Type extends ComponentClass<unknown>,\n Props extends object,\n>(Component: ComponentType<Props>, errorBoundaryProps: ErrorBoundaryProps) {\n const Wrapped = forwardRef<InstanceType<Type>, Props>((props, ref) =>\n createElement(\n ErrorBoundary,\n errorBoundaryProps,\n createElement(Component, { ...props, ref } as Props),\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"],"names":["ErrorBoundaryContext","createContext","initialState","ErrorBoundary","Component","props","error","args","info","prevProps","prevState","didCatch","resetKeys","hasArrayChanged","children","fallbackRender","FallbackComponent","fallback","childToRender","createElement","a","b","item","index","isErrorBoundaryContext","value","assertErrorBoundaryContext","useErrorBoundary","context","useContext","resetErrorBoundary","state","setState","useState","memoized","useMemo","withErrorBoundary","errorBoundaryProps","Wrapped","forwardRef","ref","name"],"mappings":"sHAQaA,EACXC,EAAAA,cAA+C,IAAI,ECO/CC,EAAmC,CACvC,SAAU,GACV,MAAO,IACT,EAkBO,MAAMC,UAAsBC,EAAAA,SAGjC,CACA,YAAYC,EAA2B,CACrC,MAAMA,CAAK,EAEX,KAAK,mBAAqB,KAAK,mBAAmB,KAAK,IAAI,EAC3D,KAAK,MAAQH,CACf,CAEA,OAAO,yBAAyBI,EAAc,CAC5C,MAAO,CAAE,SAAU,GAAM,MAAAA,CAAA,CAC3B,CAEA,sBAAsBC,EAAiB,CACrC,KAAM,CAAE,MAAAD,GAAU,KAAK,MAEnBA,IAAU,OACZ,KAAK,MAAM,UAAU,CACnB,KAAAC,EACA,OAAQ,gBAAA,CACT,EAED,KAAK,SAASL,CAAY,EAE9B,CAEA,kBAAkBI,EAAcE,EAAiB,CAC/C,KAAK,MAAM,UAAUF,EAAOE,CAAI,CAClC,CAEA,mBACEC,EACAC,EACA,CACA,KAAM,CAAE,SAAAC,GAAa,KAAK,MACpB,CAAE,UAAAC,GAAc,KAAK,MAQzBD,GACAD,EAAU,QAAU,MACpBG,EAAgBJ,EAAU,UAAWG,CAAS,IAE9C,KAAK,MAAM,UAAU,CACnB,KAAMA,EACN,KAAMH,EAAU,UAChB,OAAQ,MAAA,CACT,EAED,KAAK,SAASP,CAAY,EAE9B,CAEA,QAAS,CACP,KAAM,CAAE,SAAAY,EAAU,eAAAC,EAAgB,kBAAAC,EAAmB,SAAAC,CAAA,EACnD,KAAK,MACD,CAAE,SAAAN,EAAU,MAAAL,CAAA,EAAU,KAAK,MAEjC,IAAIY,EAAgBJ,EAEpB,GAAIH,EAAU,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AkB,CAAA,EAG5B,GAAIC,EAAM,SACR,MAAMA,EAAM,MAGd,OAAOG,CACT,CC9DO,SAASE,EAGdhC,EAAiCiC,EAAwC,CACzE,MAAMC,EAAUC,EAAAA,WAAsC,CAAClC,EAAOmC,IAC5DrB,EAAAA,cACEhB,EACAkC,EACAlB,EAAAA,cAAcf,EAAW,CAAE,GAAGC,EAAO,IAAAmC,EAAc,CAAA,CACrD,EAIIC,EAAOrC,EAAU,aAAeA,EAAU,MAAQ,UACxD,OAAAkC,EAAQ,YAAc,qBAAqBG,CAAI,IAExCH,CACT"}
|
|
1
|
+
{"version":3,"file":"react-error-boundary.cjs","sources":["../lib/context/ErrorBoundaryContext.ts","../lib/components/ErrorBoundary.tsx","../lib/utils/isErrorBoundaryContext.ts","../lib/utils/assertErrorBoundaryContext.ts","../lib/hooks/useErrorBoundary.ts","../lib/utils/getErrorMessage.ts","../lib/utils/withErrorBoundary.ts"],"sourcesContent":["import { createContext } from \"react\";\n\nexport type ErrorBoundaryContextType = {\n didCatch: boolean;\n error: unknown | null;\n resetErrorBoundary: (...args: unknown[]) => void;\n};\n\nexport const ErrorBoundaryContext =\n createContext<ErrorBoundaryContextType | null>(null);\n","import { Component, createElement, type ErrorInfo } from \"react\";\nimport { ErrorBoundaryContext } from \"../context/ErrorBoundaryContext\";\nimport type { ErrorBoundaryProps, FallbackProps } from \"../types\";\n\nconst isDevelopment = import.meta.env.DEV;\n\ntype ErrorBoundaryState =\n | {\n didCatch: true;\n error: unknown;\n }\n | {\n didCatch: false;\n error: null;\n };\n\nconst initialState: ErrorBoundaryState = {\n didCatch: false,\n error: null,\n};\n\n/**\n * A reusable React [error boundary](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary) component.\n * Wrap this component around other React components to \"catch\" errors and render a fallback UI.\n *\n * This package is built on top of React [error boundaries](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary),\n * so it has all of the advantages and constraints of that API.\n * This means that it can't catch errors during:\n * - Server side rendering</li>\n * - Event handlers\n * - Asynchronous code (including effects)\n *\n * ℹ️ The component provides several ways to render a fallback: `fallback`, `fallbackRender`, and `FallbackComponent`.\n * Refer to the documentation to determine which is best for your application.\n *\n * ℹ️ This is a **client component**. You can only pass props to it that are serializeable or use it in files that have a `\"use client\";` directive.\n */\nexport class ErrorBoundary extends Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n\n this.resetErrorBoundary = this.resetErrorBoundary.bind(this);\n this.state = initialState;\n }\n\n static getDerivedStateFromError(error: Error) {\n return { didCatch: true, error };\n }\n\n resetErrorBoundary(...args: unknown[]) {\n const { error } = this.state;\n\n if (error !== null) {\n this.props.onReset?.({\n args,\n reason: \"imperative-api\",\n });\n\n this.setState(initialState);\n }\n }\n\n componentDidCatch(error: unknown, info: ErrorInfo) {\n this.props.onError?.(error, info);\n }\n\n componentDidUpdate(\n prevProps: ErrorBoundaryProps,\n prevState: ErrorBoundaryState,\n ) {\n const { didCatch } = this.state;\n const { resetKeys } = this.props;\n\n // There's an edge case where if the thing that triggered the error happens to *also* be in the resetKeys array,\n // we'd end up resetting the error boundary immediately.\n // This would likely trigger a second error to be thrown.\n // So we make sure that we don't check the resetKeys on the first call of cDU after the error is set.\n\n if (\n didCatch &&\n prevState.error !== null &&\n hasArrayChanged(prevProps.resetKeys, resetKeys)\n ) {\n this.props.onReset?.({\n next: resetKeys,\n prev: prevProps.resetKeys,\n reason: \"keys\",\n });\n\n this.setState(initialState);\n }\n }\n\n render() {\n const { children, fallbackRender, FallbackComponent, fallback } =\n this.props;\n const { didCatch, error } = this.state;\n\n let childToRender = children;\n\n if (didCatch) {\n const props: FallbackProps = {\n error,\n resetErrorBoundary: this.resetErrorBoundary,\n };\n\n if (typeof fallbackRender === \"function\") {\n childToRender = fallbackRender(props);\n } else if (FallbackComponent) {\n childToRender = createElement(FallbackComponent, props);\n } else if (fallback !== undefined) {\n childToRender = fallback;\n } else {\n if (isDevelopment) {\n console.error(\n \"react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop\",\n );\n }\n\n throw error;\n }\n }\n\n return createElement(\n ErrorBoundaryContext.Provider,\n {\n value: {\n didCatch,\n error,\n resetErrorBoundary: this.resetErrorBoundary,\n },\n },\n childToRender,\n );\n }\n}\n\nfunction hasArrayChanged(a: unknown[] = [], b: unknown[] = []) {\n return (\n a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]))\n );\n}\n","import type { ErrorBoundaryContextType } from \"../context/ErrorBoundaryContext\";\n\nexport function isErrorBoundaryContext(\n value: unknown,\n): value is ErrorBoundaryContextType {\n return (\n value !== null &&\n typeof value === \"object\" &&\n \"didCatch\" in value &&\n typeof value.didCatch === \"boolean\" &&\n \"error\" in value &&\n \"resetErrorBoundary\" in value &&\n typeof value.resetErrorBoundary === \"function\"\n );\n}\n","import type { ErrorBoundaryContextType } from \"../context/ErrorBoundaryContext\";\nimport { isErrorBoundaryContext } from \"./isErrorBoundaryContext\";\n\nexport function assertErrorBoundaryContext(\n value: unknown,\n): asserts value is ErrorBoundaryContextType {\n if (!isErrorBoundaryContext(value)) {\n throw new Error(\"ErrorBoundaryContext not found\");\n }\n}\n","import { useContext, useMemo, useState } from \"react\";\nimport { ErrorBoundaryContext } from \"../context/ErrorBoundaryContext\";\nimport { assertErrorBoundaryContext } from \"../utils/assertErrorBoundaryContext\";\n\ntype UseErrorBoundaryState =\n | { error: unknown; hasError: true }\n | { error: null; hasError: false };\n\nexport type UseErrorBoundaryApi = {\n error: unknown | null;\n resetBoundary: () => void;\n showBoundary: (error: unknown) => void;\n};\n\n/**\n * Convenience hook for imperatively showing or dismissing error boundaries.\n *\n * ⚠️ This hook must only be used within an `ErrorBoundary` subtree.\n */\nexport function useErrorBoundary(): {\n /**\n * The currently visible `Error` (if one has been thrown).\n */\n error: unknown | null;\n\n /**\n * Method to reset and retry the nearest active error boundary (if one is active).\n */\n resetBoundary: () => void;\n\n /**\n * Trigger the nearest error boundary to display the error provided.\n *\n * ℹ️ React only handles errors thrown during render or during component lifecycle methods (e.g. effects and did-mount/did-update).\n * Errors thrown in event handlers, or after async code has run, will not be caught.\n * This method is a way to imperatively trigger an error boundary during these phases.\n */\n showBoundary: (error: unknown) => void;\n} {\n const context = useContext(ErrorBoundaryContext);\n\n assertErrorBoundaryContext(context);\n\n const { error, resetErrorBoundary } = context;\n\n const [state, setState] = useState<UseErrorBoundaryState>({\n error: null,\n hasError: false,\n });\n\n const memoized = useMemo(\n () => ({\n error,\n resetBoundary: () => {\n resetErrorBoundary();\n setState({ error: null, hasError: false });\n },\n showBoundary: (error: unknown) =>\n setState({\n error,\n hasError: true,\n }),\n }),\n [error, resetErrorBoundary],\n );\n\n if (state.hasError) {\n throw state.error;\n }\n\n return memoized;\n}\n","export function getErrorMessage(thrown: unknown): string | undefined {\n switch (typeof thrown) {\n case \"object\": {\n if (\n thrown !== null &&\n \"message\" in thrown &&\n typeof thrown.message === \"string\"\n ) {\n return thrown.message;\n }\n break;\n }\n case \"string\": {\n return thrown;\n }\n }\n}\n","import {\n createElement,\n forwardRef,\n type ComponentClass,\n type ComponentType,\n} from \"react\";\nimport { ErrorBoundary } from \"../components/ErrorBoundary\";\nimport type { ErrorBoundaryProps } from \"../types\";\n\nexport function withErrorBoundary<\n Type extends ComponentClass<unknown>,\n Props extends object,\n>(Component: ComponentType<Props>, errorBoundaryProps: ErrorBoundaryProps) {\n const Wrapped = forwardRef<InstanceType<Type>, Props>((props, ref) =>\n createElement(\n ErrorBoundary,\n errorBoundaryProps,\n createElement(Component, { ...props, ref } as Props),\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"],"names":["ErrorBoundaryContext","createContext","initialState","ErrorBoundary","Component","props","error","args","info","prevProps","prevState","didCatch","resetKeys","hasArrayChanged","children","fallbackRender","FallbackComponent","fallback","childToRender","createElement","a","b","item","index","isErrorBoundaryContext","value","assertErrorBoundaryContext","useErrorBoundary","context","useContext","resetErrorBoundary","state","setState","useState","memoized","useMemo","getErrorMessage","thrown","withErrorBoundary","errorBoundaryProps","Wrapped","forwardRef","ref","name"],"mappings":"sHAQaA,EACXC,EAAAA,cAA+C,IAAI,ECO/CC,EAAmC,CACvC,SAAU,GACV,MAAO,IACT,EAkBO,MAAMC,UAAsBC,EAAAA,SAGjC,CACA,YAAYC,EAA2B,CACrC,MAAMA,CAAK,EAEX,KAAK,mBAAqB,KAAK,mBAAmB,KAAK,IAAI,EAC3D,KAAK,MAAQH,CACf,CAEA,OAAO,yBAAyBI,EAAc,CAC5C,MAAO,CAAE,SAAU,GAAM,MAAAA,CAAA,CAC3B,CAEA,sBAAsBC,EAAiB,CACrC,KAAM,CAAE,MAAAD,GAAU,KAAK,MAEnBA,IAAU,OACZ,KAAK,MAAM,UAAU,CACnB,KAAAC,EACA,OAAQ,gBAAA,CACT,EAED,KAAK,SAASL,CAAY,EAE9B,CAEA,kBAAkBI,EAAgBE,EAAiB,CACjD,KAAK,MAAM,UAAUF,EAAOE,CAAI,CAClC,CAEA,mBACEC,EACAC,EACA,CACA,KAAM,CAAE,SAAAC,GAAa,KAAK,MACpB,CAAE,UAAAC,GAAc,KAAK,MAQzBD,GACAD,EAAU,QAAU,MACpBG,EAAgBJ,EAAU,UAAWG,CAAS,IAE9C,KAAK,MAAM,UAAU,CACnB,KAAMA,EACN,KAAMH,EAAU,UAChB,OAAQ,MAAA,CACT,EAED,KAAK,SAASP,CAAY,EAE9B,CAEA,QAAS,CACP,KAAM,CAAE,SAAAY,EAAU,eAAAC,EAAgB,kBAAAC,EAAmB,SAAAC,CAAA,EACnD,KAAK,MACD,CAAE,SAAAN,EAAU,MAAAL,CAAA,EAAU,KAAK,MAEjC,IAAIY,EAAgBJ,EAEpB,GAAIH,EAAU,CACZ,MAAMN,EAAuB,CAC3B,MAAAC,EACA,mBAAoB,KAAK,kBAAA,EAG3B,GAAI,OAAOS,GAAmB,WAC5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C,CACnE,OAAQ,OAAOA,EAAA,CACb,IAAK,SAAU,CACb,GACEA,IAAW,MACX,YAAaA,GACb,OAAOA,EAAO,SAAY,SAE1B,OAAOA,EAAO,QAEhB,KACF,CACA,IAAK,SACH,OAAOA,CACT,CAEJ,CCPO,SAASC,EAGdlC,EAAiCmC,EAAwC,CACzE,MAAMC,EAAUC,EAAAA,WAAsC,CAACpC,EAAOqC,IAC5DvB,EAAAA,cACEhB,EACAoC,EACApB,EAAAA,cAAcf,EAAW,CAAE,GAAGC,EAAO,IAAAqC,EAAc,CAAA,CACrD,EAIIC,EAAOvC,EAAU,aAAeA,EAAU,MAAQ,UACxD,OAAAoC,EAAQ,YAAc,qBAAqBG,CAAI,IAExCH,CACT"}
|
|
@@ -34,7 +34,7 @@ export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBo
|
|
|
34
34
|
error: Error;
|
|
35
35
|
};
|
|
36
36
|
resetErrorBoundary(...args: unknown[]): void;
|
|
37
|
-
componentDidCatch(error:
|
|
37
|
+
componentDidCatch(error: unknown, info: ErrorInfo): void;
|
|
38
38
|
componentDidUpdate(prevProps: ErrorBoundaryProps, prevState: ErrorBoundaryState): void;
|
|
39
39
|
render(): FunctionComponentElement<ProviderProps<ErrorBoundaryContextType | null>>;
|
|
40
40
|
}
|
|
@@ -43,7 +43,7 @@ export declare const ErrorBoundaryContext: Context<ErrorBoundaryContextType | nu
|
|
|
43
43
|
|
|
44
44
|
export declare type ErrorBoundaryContextType = {
|
|
45
45
|
didCatch: boolean;
|
|
46
|
-
error:
|
|
46
|
+
error: unknown | null;
|
|
47
47
|
resetErrorBoundary: (...args: unknown[]) => void;
|
|
48
48
|
};
|
|
49
49
|
|
|
@@ -92,10 +92,10 @@ declare type ErrorBoundarySharedProps = PropsWithChildren<{
|
|
|
92
92
|
/**
|
|
93
93
|
* Optional callback to enable e.g. logging error information to a server.
|
|
94
94
|
*
|
|
95
|
-
* @param error
|
|
95
|
+
* @param error Value that was thrown; typically an instance of `Error`
|
|
96
96
|
* @param info React "component stack" identifying where the error was thrown
|
|
97
97
|
*/
|
|
98
|
-
onError?: (error:
|
|
98
|
+
onError?: (error: unknown, info: ErrorInfo) => void;
|
|
99
99
|
/**
|
|
100
100
|
* Optional callback to to be notified when an error boundary is "reset" so React can retry the failed render.
|
|
101
101
|
*/
|
|
@@ -117,18 +117,20 @@ declare type ErrorBoundarySharedProps = PropsWithChildren<{
|
|
|
117
117
|
|
|
118
118
|
declare type ErrorBoundaryState = {
|
|
119
119
|
didCatch: true;
|
|
120
|
-
error:
|
|
120
|
+
error: unknown;
|
|
121
121
|
} | {
|
|
122
122
|
didCatch: false;
|
|
123
123
|
error: null;
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
export declare type FallbackProps = {
|
|
127
|
-
error:
|
|
127
|
+
error: unknown;
|
|
128
128
|
resetErrorBoundary: (...args: unknown[]) => void;
|
|
129
129
|
};
|
|
130
130
|
|
|
131
|
-
export declare
|
|
131
|
+
export declare function getErrorMessage(thrown: unknown): string | undefined;
|
|
132
|
+
|
|
133
|
+
export declare type OnErrorCallback = (error: unknown, info: ErrorInfo) => void;
|
|
132
134
|
|
|
133
135
|
/**
|
|
134
136
|
* Convenience hook for imperatively showing or dismissing error boundaries.
|
|
@@ -139,7 +141,7 @@ export declare function useErrorBoundary(): {
|
|
|
139
141
|
/**
|
|
140
142
|
* The currently visible `Error` (if one has been thrown).
|
|
141
143
|
*/
|
|
142
|
-
error:
|
|
144
|
+
error: unknown | null;
|
|
143
145
|
/**
|
|
144
146
|
* Method to reset and retry the nearest active error boundary (if one is active).
|
|
145
147
|
*/
|
|
@@ -151,13 +153,13 @@ export declare function useErrorBoundary(): {
|
|
|
151
153
|
* Errors thrown in event handlers, or after async code has run, will not be caught.
|
|
152
154
|
* This method is a way to imperatively trigger an error boundary during these phases.
|
|
153
155
|
*/
|
|
154
|
-
showBoundary: (error:
|
|
156
|
+
showBoundary: (error: unknown) => void;
|
|
155
157
|
};
|
|
156
158
|
|
|
157
159
|
export declare type UseErrorBoundaryApi = {
|
|
158
|
-
error:
|
|
160
|
+
error: unknown | null;
|
|
159
161
|
resetBoundary: () => void;
|
|
160
|
-
showBoundary: (error:
|
|
162
|
+
showBoundary: (error: unknown) => void;
|
|
161
163
|
};
|
|
162
164
|
|
|
163
165
|
export declare function withErrorBoundary<Type extends ComponentClass<unknown>, Props extends object>(Component: ComponentType<Props>, errorBoundaryProps: ErrorBoundaryProps): ForwardRefExoticComponent<PropsWithoutRef<Props> & RefAttributes<InstanceType<Type>>>;
|
|
@@ -5,44 +5,44 @@ const h = l(null), c = {
|
|
|
5
5
|
error: null
|
|
6
6
|
};
|
|
7
7
|
class m extends y {
|
|
8
|
-
constructor(
|
|
9
|
-
super(
|
|
8
|
+
constructor(e) {
|
|
9
|
+
super(e), this.resetErrorBoundary = this.resetErrorBoundary.bind(this), this.state = c;
|
|
10
10
|
}
|
|
11
|
-
static getDerivedStateFromError(
|
|
12
|
-
return { didCatch: !0, error:
|
|
11
|
+
static getDerivedStateFromError(e) {
|
|
12
|
+
return { didCatch: !0, error: e };
|
|
13
13
|
}
|
|
14
|
-
resetErrorBoundary(...
|
|
15
|
-
const { error:
|
|
16
|
-
|
|
17
|
-
args:
|
|
14
|
+
resetErrorBoundary(...e) {
|
|
15
|
+
const { error: t } = this.state;
|
|
16
|
+
t !== null && (this.props.onReset?.({
|
|
17
|
+
args: e,
|
|
18
18
|
reason: "imperative-api"
|
|
19
19
|
}), this.setState(c));
|
|
20
20
|
}
|
|
21
|
-
componentDidCatch(
|
|
22
|
-
this.props.onError?.(
|
|
21
|
+
componentDidCatch(e, t) {
|
|
22
|
+
this.props.onError?.(e, t);
|
|
23
23
|
}
|
|
24
|
-
componentDidUpdate(
|
|
25
|
-
const { didCatch: o } = this.state, { resetKeys:
|
|
26
|
-
o &&
|
|
27
|
-
next:
|
|
28
|
-
prev:
|
|
24
|
+
componentDidUpdate(e, t) {
|
|
25
|
+
const { didCatch: o } = this.state, { resetKeys: s } = this.props;
|
|
26
|
+
o && t.error !== null && C(e.resetKeys, s) && (this.props.onReset?.({
|
|
27
|
+
next: s,
|
|
28
|
+
prev: e.resetKeys,
|
|
29
29
|
reason: "keys"
|
|
30
30
|
}), this.setState(c));
|
|
31
31
|
}
|
|
32
32
|
render() {
|
|
33
|
-
const { children:
|
|
34
|
-
let i =
|
|
35
|
-
if (
|
|
33
|
+
const { children: e, fallbackRender: t, FallbackComponent: o, fallback: s } = this.props, { didCatch: n, error: a } = this.state;
|
|
34
|
+
let i = e;
|
|
35
|
+
if (n) {
|
|
36
36
|
const u = {
|
|
37
37
|
error: a,
|
|
38
38
|
resetErrorBoundary: this.resetErrorBoundary
|
|
39
39
|
};
|
|
40
|
-
if (typeof
|
|
41
|
-
i =
|
|
40
|
+
if (typeof t == "function")
|
|
41
|
+
i = t(u);
|
|
42
42
|
else if (o)
|
|
43
43
|
i = d(o, u);
|
|
44
|
-
else if (
|
|
45
|
-
i =
|
|
44
|
+
else if (s !== void 0)
|
|
45
|
+
i = s;
|
|
46
46
|
else
|
|
47
47
|
throw a;
|
|
48
48
|
}
|
|
@@ -50,7 +50,7 @@ class m extends y {
|
|
|
50
50
|
h.Provider,
|
|
51
51
|
{
|
|
52
52
|
value: {
|
|
53
|
-
didCatch:
|
|
53
|
+
didCatch: n,
|
|
54
54
|
error: a,
|
|
55
55
|
resetErrorBoundary: this.resetErrorBoundary
|
|
56
56
|
}
|
|
@@ -59,53 +59,65 @@ class m extends y {
|
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
function C(r = [],
|
|
63
|
-
return r.length !==
|
|
62
|
+
function C(r = [], e = []) {
|
|
63
|
+
return r.length !== e.length || r.some((t, o) => !Object.is(t, e[o]));
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function g(r) {
|
|
66
66
|
return r !== null && typeof r == "object" && "didCatch" in r && typeof r.didCatch == "boolean" && "error" in r && "resetErrorBoundary" in r && typeof r.resetErrorBoundary == "function";
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
if (!
|
|
68
|
+
function x(r) {
|
|
69
|
+
if (!g(r))
|
|
70
70
|
throw new Error("ErrorBoundaryContext not found");
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function k() {
|
|
73
73
|
const r = f(h);
|
|
74
|
-
|
|
75
|
-
const { error:
|
|
74
|
+
x(r);
|
|
75
|
+
const { error: e, resetErrorBoundary: t } = r, [o, s] = p({
|
|
76
76
|
error: null,
|
|
77
77
|
hasError: !1
|
|
78
|
-
}),
|
|
78
|
+
}), n = E(
|
|
79
79
|
() => ({
|
|
80
|
-
error:
|
|
80
|
+
error: e,
|
|
81
81
|
resetBoundary: () => {
|
|
82
|
-
|
|
82
|
+
t(), s({ error: null, hasError: !1 });
|
|
83
83
|
},
|
|
84
|
-
showBoundary: (a) =>
|
|
84
|
+
showBoundary: (a) => s({
|
|
85
85
|
error: a,
|
|
86
86
|
hasError: !0
|
|
87
87
|
})
|
|
88
88
|
}),
|
|
89
|
-
[
|
|
89
|
+
[e, t]
|
|
90
90
|
);
|
|
91
91
|
if (o.hasError)
|
|
92
92
|
throw o.error;
|
|
93
|
-
return
|
|
93
|
+
return n;
|
|
94
|
+
}
|
|
95
|
+
function S(r) {
|
|
96
|
+
switch (typeof r) {
|
|
97
|
+
case "object": {
|
|
98
|
+
if (r !== null && "message" in r && typeof r.message == "string")
|
|
99
|
+
return r.message;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
case "string":
|
|
103
|
+
return r;
|
|
104
|
+
}
|
|
94
105
|
}
|
|
95
|
-
function
|
|
96
|
-
const
|
|
97
|
-
(
|
|
106
|
+
function w(r, e) {
|
|
107
|
+
const t = B(
|
|
108
|
+
(s, n) => d(
|
|
98
109
|
m,
|
|
99
|
-
|
|
100
|
-
d(r, { ...
|
|
110
|
+
e,
|
|
111
|
+
d(r, { ...s, ref: n })
|
|
101
112
|
)
|
|
102
113
|
), o = r.displayName || r.name || "Unknown";
|
|
103
|
-
return
|
|
114
|
+
return t.displayName = `withErrorBoundary(${o})`, t;
|
|
104
115
|
}
|
|
105
116
|
export {
|
|
106
117
|
m as ErrorBoundary,
|
|
107
118
|
h as ErrorBoundaryContext,
|
|
108
|
-
S as
|
|
109
|
-
k as
|
|
119
|
+
S as getErrorMessage,
|
|
120
|
+
k as useErrorBoundary,
|
|
121
|
+
w as withErrorBoundary
|
|
110
122
|
};
|
|
111
123
|
//# sourceMappingURL=react-error-boundary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-error-boundary.js","sources":["../lib/context/ErrorBoundaryContext.ts","../lib/components/ErrorBoundary.tsx","../lib/utils/isErrorBoundaryContext.ts","../lib/utils/assertErrorBoundaryContext.ts","../lib/hooks/useErrorBoundary.ts","../lib/utils/withErrorBoundary.ts"],"sourcesContent":["import { createContext } from \"react\";\n\nexport type ErrorBoundaryContextType = {\n didCatch: boolean;\n error: Error | null;\n resetErrorBoundary: (...args: unknown[]) => void;\n};\n\nexport const ErrorBoundaryContext =\n createContext<ErrorBoundaryContextType | null>(null);\n","import { Component, createElement, type ErrorInfo } from \"react\";\nimport { ErrorBoundaryContext } from \"../context/ErrorBoundaryContext\";\nimport type { ErrorBoundaryProps, FallbackProps } from \"../types\";\n\nconst isDevelopment = import.meta.env.DEV;\n\ntype ErrorBoundaryState =\n | {\n didCatch: true;\n error: Error;\n }\n | {\n didCatch: false;\n error: null;\n };\n\nconst initialState: ErrorBoundaryState = {\n didCatch: false,\n error: null,\n};\n\n/**\n * A reusable React [error boundary](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary) component.\n * Wrap this component around other React components to \"catch\" errors and render a fallback UI.\n *\n * This package is built on top of React [error boundaries](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary),\n * so it has all of the advantages and constraints of that API.\n * This means that it can't catch errors during:\n * - Server side rendering</li>\n * - Event handlers\n * - Asynchronous code (including effects)\n *\n * ℹ️ The component provides several ways to render a fallback: `fallback`, `fallbackRender`, and `FallbackComponent`.\n * Refer to the documentation to determine which is best for your application.\n *\n * ℹ️ This is a **client component**. You can only pass props to it that are serializeable or use it in files that have a `\"use client\";` directive.\n */\nexport class ErrorBoundary extends Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n\n this.resetErrorBoundary = this.resetErrorBoundary.bind(this);\n this.state = initialState;\n }\n\n static getDerivedStateFromError(error: Error) {\n return { didCatch: true, error };\n }\n\n resetErrorBoundary(...args: unknown[]) {\n const { error } = this.state;\n\n if (error !== null) {\n this.props.onReset?.({\n args,\n reason: \"imperative-api\",\n });\n\n this.setState(initialState);\n }\n }\n\n componentDidCatch(error: Error, info: ErrorInfo) {\n this.props.onError?.(error, info);\n }\n\n componentDidUpdate(\n prevProps: ErrorBoundaryProps,\n prevState: ErrorBoundaryState,\n ) {\n const { didCatch } = this.state;\n const { resetKeys } = this.props;\n\n // There's an edge case where if the thing that triggered the error happens to *also* be in the resetKeys array,\n // we'd end up resetting the error boundary immediately.\n // This would likely trigger a second error to be thrown.\n // So we make sure that we don't check the resetKeys on the first call of cDU after the error is set.\n\n if (\n didCatch &&\n prevState.error !== null &&\n hasArrayChanged(prevProps.resetKeys, resetKeys)\n ) {\n this.props.onReset?.({\n next: resetKeys,\n prev: prevProps.resetKeys,\n reason: \"keys\",\n });\n\n this.setState(initialState);\n }\n }\n\n render() {\n const { children, fallbackRender, FallbackComponent, fallback } =\n this.props;\n const { didCatch, error } = this.state;\n\n let childToRender = children;\n\n if (didCatch) {\n const props: FallbackProps = {\n error,\n resetErrorBoundary: this.resetErrorBoundary,\n };\n\n if (typeof fallbackRender === \"function\") {\n childToRender = fallbackRender(props);\n } else if (FallbackComponent) {\n childToRender = createElement(FallbackComponent, props);\n } else if (fallback !== undefined) {\n childToRender = fallback;\n } else {\n if (isDevelopment) {\n console.error(\n \"react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop\",\n );\n }\n\n throw error;\n }\n }\n\n return createElement(\n ErrorBoundaryContext.Provider,\n {\n value: {\n didCatch,\n error,\n resetErrorBoundary: this.resetErrorBoundary,\n },\n },\n childToRender,\n );\n }\n}\n\nfunction hasArrayChanged(a: unknown[] = [], b: unknown[] = []) {\n return (\n a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]))\n );\n}\n","import type { ErrorBoundaryContextType } from \"../context/ErrorBoundaryContext\";\n\nexport function isErrorBoundaryContext(\n value: unknown,\n): value is ErrorBoundaryContextType {\n return (\n value !== null &&\n typeof value === \"object\" &&\n \"didCatch\" in value &&\n typeof value.didCatch === \"boolean\" &&\n \"error\" in value &&\n \"resetErrorBoundary\" in value &&\n typeof value.resetErrorBoundary === \"function\"\n );\n}\n","import type { ErrorBoundaryContextType } from \"../context/ErrorBoundaryContext\";\nimport { isErrorBoundaryContext } from \"./isErrorBoundaryContext\";\n\nexport function assertErrorBoundaryContext(\n value: unknown,\n): asserts value is ErrorBoundaryContextType {\n if (!isErrorBoundaryContext(value)) {\n throw new Error(\"ErrorBoundaryContext not found\");\n }\n}\n","import { useContext, useMemo, useState } from \"react\";\nimport { ErrorBoundaryContext } from \"../context/ErrorBoundaryContext\";\nimport { assertErrorBoundaryContext } from \"../utils/assertErrorBoundaryContext\";\n\ntype UseErrorBoundaryState =\n | { error: Error; hasError: true }\n | { error: null; hasError: false };\n\nexport type UseErrorBoundaryApi = {\n error: Error | null;\n resetBoundary: () => void;\n showBoundary: (error: Error) => void;\n};\n\n/**\n * Convenience hook for imperatively showing or dismissing error boundaries.\n *\n * ⚠️ This hook must only be used within an `ErrorBoundary` subtree.\n */\nexport function useErrorBoundary(): {\n /**\n * The currently visible `Error` (if one has been thrown).\n */\n error: Error | null;\n\n /**\n * Method to reset and retry the nearest active error boundary (if one is active).\n */\n resetBoundary: () => void;\n\n /**\n * Trigger the nearest error boundary to display the error provided.\n *\n * ℹ️ React only handles errors thrown during render or during component lifecycle methods (e.g. effects and did-mount/did-update).\n * Errors thrown in event handlers, or after async code has run, will not be caught.\n * This method is a way to imperatively trigger an error boundary during these phases.\n */\n showBoundary: (error: Error) => void;\n} {\n const context = useContext(ErrorBoundaryContext);\n\n assertErrorBoundaryContext(context);\n\n const { error, resetErrorBoundary } = context;\n\n const [state, setState] = useState<UseErrorBoundaryState>({\n error: null,\n hasError: false,\n });\n\n const memoized = useMemo(\n () => ({\n error,\n resetBoundary: () => {\n resetErrorBoundary();\n setState({ error: null, hasError: false });\n },\n showBoundary: (error: Error) =>\n setState({\n error,\n hasError: true,\n }),\n }),\n [error, resetErrorBoundary],\n );\n\n if (state.hasError) {\n throw state.error;\n }\n\n return memoized;\n}\n","import {\n createElement,\n forwardRef,\n type ComponentClass,\n type ComponentType,\n} from \"react\";\nimport { ErrorBoundary } from \"../components/ErrorBoundary\";\nimport type { ErrorBoundaryProps } from \"../types\";\n\nexport function withErrorBoundary<\n Type extends ComponentClass<unknown>,\n Props extends object,\n>(Component: ComponentType<Props>, errorBoundaryProps: ErrorBoundaryProps) {\n const Wrapped = forwardRef<InstanceType<Type>, Props>((props, ref) =>\n createElement(\n ErrorBoundary,\n errorBoundaryProps,\n createElement(Component, { ...props, ref } as Props),\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"],"names":["ErrorBoundaryContext","createContext","initialState","ErrorBoundary","Component","props","error","args","info","prevProps","prevState","didCatch","resetKeys","hasArrayChanged","children","fallbackRender","FallbackComponent","fallback","childToRender","createElement","a","b","item","index","isErrorBoundaryContext","value","assertErrorBoundaryContext","useErrorBoundary","context","useContext","resetErrorBoundary","state","setState","useState","memoized","useMemo","withErrorBoundary","errorBoundaryProps","Wrapped","forwardRef","ref","name"],"mappings":";;AAQO,MAAMA,IACXC,EAA+C,IAAI,GCO/CC,IAAmC;AAAA,EACvC,UAAU;AAAA,EACV,OAAO;AACT;AAkBO,MAAMC,UAA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B,MAAIC,EAAM;AACR,UAAMA,EAAM;AAGd,SAAOG;AACT;AC9DO,SAASE,EAGdhC,GAAiCiC,GAAwC;AACzE,QAAMC,IAAUC;AAAA,IAAsC,CAAClC,GAAOmC,MAC5DrB;AAAA,MACEhB;AAAA,MACAkC;AAAA,MACAlB,EAAcf,GAAW,EAAE,GAAGC,GAAO,KAAAmC,GAAc;AAAA,IAAA;AAAA,EACrD,GAIIC,IAAOrC,EAAU,eAAeA,EAAU,QAAQ;AACxD,SAAAkC,EAAQ,cAAc,qBAAqBG,CAAI,KAExCH;AACT;"}
|
|
1
|
+
{"version":3,"file":"react-error-boundary.js","sources":["../lib/context/ErrorBoundaryContext.ts","../lib/components/ErrorBoundary.tsx","../lib/utils/isErrorBoundaryContext.ts","../lib/utils/assertErrorBoundaryContext.ts","../lib/hooks/useErrorBoundary.ts","../lib/utils/getErrorMessage.ts","../lib/utils/withErrorBoundary.ts"],"sourcesContent":["import { createContext } from \"react\";\n\nexport type ErrorBoundaryContextType = {\n didCatch: boolean;\n error: unknown | null;\n resetErrorBoundary: (...args: unknown[]) => void;\n};\n\nexport const ErrorBoundaryContext =\n createContext<ErrorBoundaryContextType | null>(null);\n","import { Component, createElement, type ErrorInfo } from \"react\";\nimport { ErrorBoundaryContext } from \"../context/ErrorBoundaryContext\";\nimport type { ErrorBoundaryProps, FallbackProps } from \"../types\";\n\nconst isDevelopment = import.meta.env.DEV;\n\ntype ErrorBoundaryState =\n | {\n didCatch: true;\n error: unknown;\n }\n | {\n didCatch: false;\n error: null;\n };\n\nconst initialState: ErrorBoundaryState = {\n didCatch: false,\n error: null,\n};\n\n/**\n * A reusable React [error boundary](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary) component.\n * Wrap this component around other React components to \"catch\" errors and render a fallback UI.\n *\n * This package is built on top of React [error boundaries](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary),\n * so it has all of the advantages and constraints of that API.\n * This means that it can't catch errors during:\n * - Server side rendering</li>\n * - Event handlers\n * - Asynchronous code (including effects)\n *\n * ℹ️ The component provides several ways to render a fallback: `fallback`, `fallbackRender`, and `FallbackComponent`.\n * Refer to the documentation to determine which is best for your application.\n *\n * ℹ️ This is a **client component**. You can only pass props to it that are serializeable or use it in files that have a `\"use client\";` directive.\n */\nexport class ErrorBoundary extends Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n constructor(props: ErrorBoundaryProps) {\n super(props);\n\n this.resetErrorBoundary = this.resetErrorBoundary.bind(this);\n this.state = initialState;\n }\n\n static getDerivedStateFromError(error: Error) {\n return { didCatch: true, error };\n }\n\n resetErrorBoundary(...args: unknown[]) {\n const { error } = this.state;\n\n if (error !== null) {\n this.props.onReset?.({\n args,\n reason: \"imperative-api\",\n });\n\n this.setState(initialState);\n }\n }\n\n componentDidCatch(error: unknown, info: ErrorInfo) {\n this.props.onError?.(error, info);\n }\n\n componentDidUpdate(\n prevProps: ErrorBoundaryProps,\n prevState: ErrorBoundaryState,\n ) {\n const { didCatch } = this.state;\n const { resetKeys } = this.props;\n\n // There's an edge case where if the thing that triggered the error happens to *also* be in the resetKeys array,\n // we'd end up resetting the error boundary immediately.\n // This would likely trigger a second error to be thrown.\n // So we make sure that we don't check the resetKeys on the first call of cDU after the error is set.\n\n if (\n didCatch &&\n prevState.error !== null &&\n hasArrayChanged(prevProps.resetKeys, resetKeys)\n ) {\n this.props.onReset?.({\n next: resetKeys,\n prev: prevProps.resetKeys,\n reason: \"keys\",\n });\n\n this.setState(initialState);\n }\n }\n\n render() {\n const { children, fallbackRender, FallbackComponent, fallback } =\n this.props;\n const { didCatch, error } = this.state;\n\n let childToRender = children;\n\n if (didCatch) {\n const props: FallbackProps = {\n error,\n resetErrorBoundary: this.resetErrorBoundary,\n };\n\n if (typeof fallbackRender === \"function\") {\n childToRender = fallbackRender(props);\n } else if (FallbackComponent) {\n childToRender = createElement(FallbackComponent, props);\n } else if (fallback !== undefined) {\n childToRender = fallback;\n } else {\n if (isDevelopment) {\n console.error(\n \"react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop\",\n );\n }\n\n throw error;\n }\n }\n\n return createElement(\n ErrorBoundaryContext.Provider,\n {\n value: {\n didCatch,\n error,\n resetErrorBoundary: this.resetErrorBoundary,\n },\n },\n childToRender,\n );\n }\n}\n\nfunction hasArrayChanged(a: unknown[] = [], b: unknown[] = []) {\n return (\n a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]))\n );\n}\n","import type { ErrorBoundaryContextType } from \"../context/ErrorBoundaryContext\";\n\nexport function isErrorBoundaryContext(\n value: unknown,\n): value is ErrorBoundaryContextType {\n return (\n value !== null &&\n typeof value === \"object\" &&\n \"didCatch\" in value &&\n typeof value.didCatch === \"boolean\" &&\n \"error\" in value &&\n \"resetErrorBoundary\" in value &&\n typeof value.resetErrorBoundary === \"function\"\n );\n}\n","import type { ErrorBoundaryContextType } from \"../context/ErrorBoundaryContext\";\nimport { isErrorBoundaryContext } from \"./isErrorBoundaryContext\";\n\nexport function assertErrorBoundaryContext(\n value: unknown,\n): asserts value is ErrorBoundaryContextType {\n if (!isErrorBoundaryContext(value)) {\n throw new Error(\"ErrorBoundaryContext not found\");\n }\n}\n","import { useContext, useMemo, useState } from \"react\";\nimport { ErrorBoundaryContext } from \"../context/ErrorBoundaryContext\";\nimport { assertErrorBoundaryContext } from \"../utils/assertErrorBoundaryContext\";\n\ntype UseErrorBoundaryState =\n | { error: unknown; hasError: true }\n | { error: null; hasError: false };\n\nexport type UseErrorBoundaryApi = {\n error: unknown | null;\n resetBoundary: () => void;\n showBoundary: (error: unknown) => void;\n};\n\n/**\n * Convenience hook for imperatively showing or dismissing error boundaries.\n *\n * ⚠️ This hook must only be used within an `ErrorBoundary` subtree.\n */\nexport function useErrorBoundary(): {\n /**\n * The currently visible `Error` (if one has been thrown).\n */\n error: unknown | null;\n\n /**\n * Method to reset and retry the nearest active error boundary (if one is active).\n */\n resetBoundary: () => void;\n\n /**\n * Trigger the nearest error boundary to display the error provided.\n *\n * ℹ️ React only handles errors thrown during render or during component lifecycle methods (e.g. effects and did-mount/did-update).\n * Errors thrown in event handlers, or after async code has run, will not be caught.\n * This method is a way to imperatively trigger an error boundary during these phases.\n */\n showBoundary: (error: unknown) => void;\n} {\n const context = useContext(ErrorBoundaryContext);\n\n assertErrorBoundaryContext(context);\n\n const { error, resetErrorBoundary } = context;\n\n const [state, setState] = useState<UseErrorBoundaryState>({\n error: null,\n hasError: false,\n });\n\n const memoized = useMemo(\n () => ({\n error,\n resetBoundary: () => {\n resetErrorBoundary();\n setState({ error: null, hasError: false });\n },\n showBoundary: (error: unknown) =>\n setState({\n error,\n hasError: true,\n }),\n }),\n [error, resetErrorBoundary],\n );\n\n if (state.hasError) {\n throw state.error;\n }\n\n return memoized;\n}\n","export function getErrorMessage(thrown: unknown): string | undefined {\n switch (typeof thrown) {\n case \"object\": {\n if (\n thrown !== null &&\n \"message\" in thrown &&\n typeof thrown.message === \"string\"\n ) {\n return thrown.message;\n }\n break;\n }\n case \"string\": {\n return thrown;\n }\n }\n}\n","import {\n createElement,\n forwardRef,\n type ComponentClass,\n type ComponentType,\n} from \"react\";\nimport { ErrorBoundary } from \"../components/ErrorBoundary\";\nimport type { ErrorBoundaryProps } from \"../types\";\n\nexport function withErrorBoundary<\n Type extends ComponentClass<unknown>,\n Props extends object,\n>(Component: ComponentType<Props>, errorBoundaryProps: ErrorBoundaryProps) {\n const Wrapped = forwardRef<InstanceType<Type>, Props>((props, ref) =>\n createElement(\n ErrorBoundary,\n errorBoundaryProps,\n createElement(Component, { ...props, ref } as Props),\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"],"names":["ErrorBoundaryContext","createContext","initialState","ErrorBoundary","Component","props","error","args","info","prevProps","prevState","didCatch","resetKeys","hasArrayChanged","children","fallbackRender","FallbackComponent","fallback","childToRender","createElement","a","b","item","index","isErrorBoundaryContext","value","assertErrorBoundaryContext","useErrorBoundary","context","useContext","resetErrorBoundary","state","setState","useState","memoized","useMemo","getErrorMessage","thrown","withErrorBoundary","errorBoundaryProps","Wrapped","forwardRef","ref","name"],"mappings":";;AAQO,MAAMA,IACXC,EAA+C,IAAI,GCO/CC,IAAmC;AAAA,EACvC,UAAU;AAAA,EACV,OAAO;AACT;AAkBO,MAAMC,UAAsBC,EAGjC;AAAA,EACA,YAAYC,GAA2B;AACrC,UAAMA,CAAK,GAEX,KAAK,qBAAqB,KAAK,mBAAmB,KAAK,IAAI,GAC3D,KAAK,QAAQH;AAAA,EACf;AAAA,EAEA,OAAO,yBAAyBI,GAAc;AAC5C,WAAO,EAAE,UAAU,IAAM,OAAAA,EAAA;AAAA,EAC3B;AAAA,EAEA,sBAAsBC,GAAiB;AACrC,UAAM,EAAE,OAAAD,MAAU,KAAK;AAEvB,IAAIA,MAAU,SACZ,KAAK,MAAM,UAAU;AAAA,MACnB,MAAAC;AAAA,MACA,QAAQ;AAAA,IAAA,CACT,GAED,KAAK,SAASL,CAAY;AAAA,EAE9B;AAAA,EAEA,kBAAkBI,GAAgBE,GAAiB;AACjD,SAAK,MAAM,UAAUF,GAAOE,CAAI;AAAA,EAClC;AAAA,EAEA,mBACEC,GACAC,GACA;AACA,UAAM,EAAE,UAAAC,MAAa,KAAK,OACpB,EAAE,WAAAC,MAAc,KAAK;AAO3B,IACED,KACAD,EAAU,UAAU,QACpBG,EAAgBJ,EAAU,WAAWG,CAAS,MAE9C,KAAK,MAAM,UAAU;AAAA,MACnB,MAAMA;AAAA,MACN,MAAMH,EAAU;AAAA,MAChB,QAAQ;AAAA,IAAA,CACT,GAED,KAAK,SAASP,CAAY;AAAA,EAE9B;AAAA,EAEA,SAAS;AACP,UAAM,EAAE,UAAAY,GAAU,gBAAAC,GAAgB,mBAAAC,GAAmB,UAAAC,EAAA,IACnD,KAAK,OACD,EAAE,UAAAN,GAAU,OAAAL,EAAA,IAAU,KAAK;AAEjC,QAAIY,IAAg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e,MAAM;AACnB,QAAAwB,EAAA,GACAE,EAAS,EAAE,OAAO,MAAM,UAAU,IAAO;AAAA,MAC3C;AAAA,MACA,cAAc,CAAC1B,MACb0B,EAAS;AAAA,QACP,OAAA1B;AAAAA,QACA,UAAU;AAAA,MAAA,CACX;AAAA,IAAA;AAAA,IAEL,CAACA,GAAOwB,CAAkB;AAAA,EAAA;AAG5B,MAAIC,EAAM;AACR,UAAMA,EAAM;AAGd,SAAOG;AACT;ACvEO,SAASE,EAAgBC,GAAqC;AACnE,UAAQ,OAAOA,GAAA;AAAA,IACb,KAAK,UAAU;AACb,UACEA,MAAW,QACX,aAAaA,KACb,OAAOA,EAAO,WAAY;AAE1B,eAAOA,EAAO;AAEhB;AAAA,IACF;AAAA,IACA,KAAK;AACH,aAAOA;AAAA,EACT;AAEJ;ACPO,SAASC,EAGdlC,GAAiCmC,GAAwC;AACzE,QAAMC,IAAUC;AAAA,IAAsC,CAACpC,GAAOqC,MAC5DvB;AAAA,MACEhB;AAAA,MACAoC;AAAA,MACApB,EAAcf,GAAW,EAAE,GAAGC,GAAO,KAAAqC,GAAc;AAAA,IAAA;AAAA,EACrD,GAIIC,IAAOvC,EAAU,eAAeA,EAAU,QAAQ;AACxD,SAAAoC,EAAQ,cAAc,qBAAqBG,CAAI,KAExCH;AACT;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-error-boundary",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Simple reusable React error boundary component",
|
|
6
6
|
"author": "Brian Vaughn <brian.david.vaughn@gmail.com>",
|
|
@@ -57,8 +57,7 @@
|
|
|
57
57
|
"**/*": "prettier --write --ignore-unknown"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"react": "^18.0.0 || ^19.0.0"
|
|
61
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
60
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
62
61
|
},
|
|
63
62
|
"devDependencies": {
|
|
64
63
|
"@csstools/postcss-oklab-function": "^4.0.11",
|