react-error-boundary
Advanced tools
Comparing version 4.0.11 to 4.0.12
import { Component, ErrorInfo } from "react"; | ||
import { ErrorBoundaryProps } from "./types.js"; | ||
type ErrorBoundaryState = { | ||
didCatch: boolean; | ||
didCatch: true; | ||
error: any; | ||
} | { | ||
didCatch: false; | ||
error: null; | ||
}; | ||
@@ -7,0 +10,0 @@ export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> { |
@@ -1,5 +0,5 @@ | ||
export type UseErrorBoundaryApi<Error> = { | ||
export type UseErrorBoundaryApi<TError> = { | ||
resetBoundary: () => void; | ||
showBoundary: (error: Error) => void; | ||
showBoundary: (error: TError) => void; | ||
}; | ||
export declare function useErrorBoundary<Error = any>(): UseErrorBoundaryApi<Error>; | ||
export declare function useErrorBoundary<TError = any>(): UseErrorBoundaryApi<TError>; |
@@ -86,8 +86,8 @@ 'use client'; | ||
}; | ||
if (react.isValidElement(fallback)) { | ||
childToRender = fallback; | ||
} else if (typeof fallbackRender === "function") { | ||
if (typeof fallbackRender === "function") { | ||
childToRender = fallbackRender(props); | ||
} else if (FallbackComponent) { | ||
childToRender = react.createElement(FallbackComponent, props); | ||
} else if (fallback === null || react.isValidElement(fallback)) { | ||
childToRender = fallback; | ||
} else { | ||
@@ -116,3 +116,2 @@ throw error; | ||
} | ||
return true; | ||
} | ||
@@ -129,3 +128,3 @@ | ||
resetBoundary: () => { | ||
context === null || context === void 0 ? void 0 : context.resetErrorBoundary(); | ||
context.resetErrorBoundary(); | ||
setState({ | ||
@@ -140,3 +139,3 @@ error: null, | ||
}) | ||
}), [context === null || context === void 0 ? void 0 : context.resetErrorBoundary]); | ||
}), [context.resetErrorBoundary]); | ||
if (state.hasError) { | ||
@@ -143,0 +142,0 @@ throw state.error; |
@@ -86,8 +86,8 @@ 'use client'; | ||
}; | ||
if (react.isValidElement(fallback)) { | ||
childToRender = fallback; | ||
} else if (typeof fallbackRender === "function") { | ||
if (typeof fallbackRender === "function") { | ||
childToRender = fallbackRender(props); | ||
} else if (FallbackComponent) { | ||
childToRender = react.createElement(FallbackComponent, props); | ||
} else if (fallback === null || react.isValidElement(fallback)) { | ||
childToRender = fallback; | ||
} else { | ||
@@ -119,3 +119,2 @@ { | ||
} | ||
return true; | ||
} | ||
@@ -132,3 +131,3 @@ | ||
resetBoundary: () => { | ||
context === null || context === void 0 ? void 0 : context.resetErrorBoundary(); | ||
context.resetErrorBoundary(); | ||
setState({ | ||
@@ -143,3 +142,3 @@ error: null, | ||
}) | ||
}), [context === null || context === void 0 ? void 0 : context.resetErrorBoundary]); | ||
}), [context.resetErrorBoundary]); | ||
if (state.hasError) { | ||
@@ -146,0 +145,0 @@ throw state.error; |
'use client'; | ||
import { createContext, Component, isValidElement, createElement, useContext, useState, useMemo, forwardRef } from 'react'; | ||
import { createContext, Component, createElement, isValidElement, useContext, useState, useMemo, forwardRef } from 'react'; | ||
@@ -82,8 +82,8 @@ const ErrorBoundaryContext = createContext(null); | ||
}; | ||
if (isValidElement(fallback)) { | ||
childToRender = fallback; | ||
} else if (typeof fallbackRender === "function") { | ||
if (typeof fallbackRender === "function") { | ||
childToRender = fallbackRender(props); | ||
} else if (FallbackComponent) { | ||
childToRender = createElement(FallbackComponent, props); | ||
} else if (fallback === null || isValidElement(fallback)) { | ||
childToRender = fallback; | ||
} else { | ||
@@ -115,3 +115,2 @@ { | ||
} | ||
return true; | ||
} | ||
@@ -128,3 +127,3 @@ | ||
resetBoundary: () => { | ||
context === null || context === void 0 ? void 0 : context.resetErrorBoundary(); | ||
context.resetErrorBoundary(); | ||
setState({ | ||
@@ -139,3 +138,3 @@ error: null, | ||
}) | ||
}), [context === null || context === void 0 ? void 0 : context.resetErrorBoundary]); | ||
}), [context.resetErrorBoundary]); | ||
if (state.hasError) { | ||
@@ -142,0 +141,0 @@ throw state.error; |
'use client'; | ||
import { createContext, Component, isValidElement, createElement, useContext, useState, useMemo, forwardRef } from 'react'; | ||
import { createContext, Component, createElement, isValidElement, useContext, useState, useMemo, forwardRef } from 'react'; | ||
@@ -82,8 +82,8 @@ const ErrorBoundaryContext = createContext(null); | ||
}; | ||
if (isValidElement(fallback)) { | ||
childToRender = fallback; | ||
} else if (typeof fallbackRender === "function") { | ||
if (typeof fallbackRender === "function") { | ||
childToRender = fallbackRender(props); | ||
} else if (FallbackComponent) { | ||
childToRender = createElement(FallbackComponent, props); | ||
} else if (fallback === null || isValidElement(fallback)) { | ||
childToRender = fallback; | ||
} else { | ||
@@ -112,3 +112,2 @@ throw error; | ||
} | ||
return true; | ||
} | ||
@@ -125,3 +124,3 @@ | ||
resetBoundary: () => { | ||
context === null || context === void 0 ? void 0 : context.resetErrorBoundary(); | ||
context.resetErrorBoundary(); | ||
setState({ | ||
@@ -136,3 +135,3 @@ error: null, | ||
}) | ||
}), [context === null || context === void 0 ? void 0 : context.resetErrorBoundary]); | ||
}), [context.resetErrorBoundary]); | ||
if (state.hasError) { | ||
@@ -139,0 +138,0 @@ throw state.error; |
{ | ||
"name": "react-error-boundary", | ||
"version": "4.0.11", | ||
"version": "4.0.12", | ||
"description": "Simple reusable React error boundary component", | ||
@@ -5,0 +5,0 @@ "author": "Brian Vaughn <brian.david.vaughn@gmail.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32860
673