Skip to content

Commit

Permalink
ts: enhance
Browse files Browse the repository at this point in the history
  • Loading branch information
yinkaihui committed Apr 26, 2024
1 parent 2c693fa commit 0a10472
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions components/Image/image.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useEffect, useMemo, LegacyRef, useRef } from 'react';
import React, { useContext, useEffect, useMemo, LegacyRef, useRef, SyntheticEvent } from 'react';
import cs from '../_util/classNames';
import { ConfigContext } from '../ConfigProvider';
import IconLoading from '../../icon/react-icon/IconLoading';
Expand Down Expand Up @@ -114,7 +114,7 @@ function Image(baseProps: ImagePropsType, ref: LegacyRef<HTMLDivElement>) {

const refImg = useRef<HTMLImageElement>();

function onImgLoaded(e) {
function onImgLoaded(e: SyntheticEvent<HTMLImageElement>) {
loaded.current = true;
setStatus('loaded');
onLoad && onLoad(e);
Expand Down
13 changes: 10 additions & 3 deletions components/Image/interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { CSSProperties, ReactNode, HTMLAttributes, ImgHTMLAttributes, ReactElement } from 'react';
import {
CSSProperties,
ReactNode,
HTMLAttributes,
ImgHTMLAttributes,
ReactElement,
SyntheticEvent,
} from 'react';

/**
* @title Image
Expand Down Expand Up @@ -89,12 +96,12 @@ export interface ImageProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, 'c
* @zh 图片加载完成时触发
* @en Triggered when the image is loaded
*/
onLoad?: (ev: Event) => void;
onLoad?: (ev: SyntheticEvent<HTMLImageElement>) => void;
/**
* @zh 图片加载失败时触发
* @en Triggered when image loading fails
*/
onError?: (ev: Event) => void;
onError?: (ev: SyntheticEvent<HTMLImageElement>) => void;
}

/**
Expand Down

0 comments on commit 0a10472

Please sign in to comment.