mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-08 19:22:44 +08:00
chore(deps): update dependency @eslint-react/eslint-plugin to v3 (#6522)
* chore(deps): update dependency @eslint-react/eslint-plugin to v3 * chore: remove deprecated rules * chore: remove eslint from pre-push * chore: update lint-staged config --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Slinetrac <realakayuki@gmail.com>
This commit is contained in:
co-authored by
renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Slinetrac
parent
5ab02e2ef5
commit
13538914be
@@ -1,36 +0,0 @@
|
||||
import React from 'react'
|
||||
import type { ErrorInfo } from 'react'
|
||||
|
||||
import {
|
||||
TrafficErrorBoundary,
|
||||
LightweightTrafficErrorBoundary,
|
||||
} from './traffic-error-boundary'
|
||||
|
||||
interface WithTrafficErrorBoundaryOptions {
|
||||
lightweight?: boolean
|
||||
onError?: (error: Error, errorInfo: ErrorInfo) => void
|
||||
}
|
||||
|
||||
/**
|
||||
* HOC:为任何组件添加流量错误边界
|
||||
*/
|
||||
export function withTrafficErrorBoundary<P extends object>(
|
||||
WrappedComponent: React.ComponentType<P>,
|
||||
options?: WithTrafficErrorBoundaryOptions,
|
||||
) {
|
||||
const WithErrorBoundaryComponent = (props: P) => {
|
||||
const ErrorBoundaryComponent = options?.lightweight
|
||||
? LightweightTrafficErrorBoundary
|
||||
: TrafficErrorBoundary
|
||||
|
||||
return (
|
||||
<ErrorBoundaryComponent onError={options?.onError}>
|
||||
<WrappedComponent {...props} />
|
||||
</ErrorBoundaryComponent>
|
||||
)
|
||||
}
|
||||
|
||||
WithErrorBoundaryComponent.displayName = `withTrafficErrorBoundary(${WrappedComponent.displayName || WrappedComponent.name})`
|
||||
|
||||
return WithErrorBoundaryComponent
|
||||
}
|
||||
Reference in New Issue
Block a user