chore: replace all cn comments of fe to en version by volc api (#320)
This commit is contained in:
@@ -27,7 +27,7 @@ import React, { useCallback, version } from 'react';
|
||||
import { ApiError } from '../slardar/utils';
|
||||
import { useLogger, type Logger } from '../logger';
|
||||
|
||||
// 拷贝自 react-error-boundary@3.1.4版本源码
|
||||
// Copy from react-error-boundary@3.1.4 version source code
|
||||
function useErrorHandler(givenError?: unknown): (error: unknown) => void {
|
||||
const [error, setError] = React.useState<unknown>(null);
|
||||
if (givenError !== null && givenError !== undefined) {
|
||||
@@ -45,15 +45,15 @@ export { useErrorBoundary, useErrorHandler, type FallbackProps };
|
||||
|
||||
export type ErrorBoundaryProps = ReactErrorBoundaryProps & {
|
||||
/**
|
||||
* @description componentDidCatch 触发该回调函数,参数透传自 componentDidCatch 的两个参数
|
||||
* @param error 具体错误
|
||||
* @Description The callback function is triggered by component DidCatch, and the parameters are passed through from the two parameters of component DidCatch
|
||||
* @param error specific error
|
||||
* @param info
|
||||
* @returns
|
||||
*/
|
||||
onError?: (error: Error, info: ErrorInfo) => void;
|
||||
/**
|
||||
* @description 可在该回调函数中重置组件的一些 state,以避免一些错误的再次发生
|
||||
* @param details reset 后
|
||||
* @Description can reset some state of the component in this callback function to prevent some errors from happening again
|
||||
* @param details reset
|
||||
* @returns
|
||||
*/
|
||||
onReset?: (
|
||||
@@ -63,18 +63,18 @@ export type ErrorBoundaryProps = ReactErrorBoundaryProps & {
|
||||
) => void;
|
||||
resetKeys?: [];
|
||||
/**
|
||||
* logger 实例。默认从 LoggerContext 中读取
|
||||
* Logger instance. Read from LoggerContext by default
|
||||
*/
|
||||
// logger?: Logger;
|
||||
logger?: Logger;
|
||||
/**
|
||||
* 发生错误展示的兜底组件
|
||||
* The bottom cover component of the error display occurred.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
FallbackComponent: ComponentType<FallbackProps>;
|
||||
/**
|
||||
* errorBoundaryName,用于在发生错误时上报
|
||||
* 事件:react_error_collection / react_error_by_api_collection
|
||||
* errorBoundaryName to report when an error occurs
|
||||
* Event: react_error_collection/react_error_by_api_collection
|
||||
*/
|
||||
errorBoundaryName: string;
|
||||
};
|
||||
@@ -99,7 +99,7 @@ export const ErrorBoundary: React.FC<ErrorBoundaryProps> = ({
|
||||
const { componentStack } = info;
|
||||
|
||||
const meta = {
|
||||
reportJsError: true, // 标记为 JS Error,上报走 slardar.captureException
|
||||
reportJsError: true, // Marked as JS Error, report slardar.captureException
|
||||
errorBoundaryName,
|
||||
reactInfo: {
|
||||
componentStack,
|
||||
|
||||
Reference in New Issue
Block a user