Module exposing: catchError
// Source: https://github.com/youzan/zent | License: MIT | Copyright 2016-present Youzan
// Provided via justclaw.it.com; keep this notice with the code.
import ErrorBoundary, {
IErrorBoundaryFallbackComponentProps,
} from './ErrorBoundary';
export interface ICatchErrorOption {
onError?: (error: Error, componentStack: string) => void;
FallbackComponent?: React.ComponentType<IErrorBoundaryFallbackComponentProps>;
}
function catchError({ FallbackComponent, onError }: ICatchErrorOption = {}) {
return function catchErrorInner<P>(BaseComponent: React.ComponentType<P>) {
return function CatchError(props: P) {
return (
<ErrorBoundary FallbackComponent={FallbackComponent} onError={onError}>
<BaseComponent {...props} />
</ErrorBoundary>
);
};
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key