Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/rc-ui-lib/src/datetime-picker/TimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import React, {
useImperativeHandle,
useCallback,
} from 'react';
import { Picker } from '..';
import { Picker } from '../picker';
import { DateTimePickerInstance, TimePickerProps } from './PropsType';
import { PickerInstance } from '../picker';
import { useUpdateEffect } from '../hooks';
import { padZero, range } from '../utils';
import { times } from './utils';
import useRefState from '../hooks/use-ref-state';
import { doubleRaf } from '../utils/raf';

import type { PickerInstance } from '../picker';


const TimePicker = forwardRef<DateTimePickerInstance, TimePickerProps>((props, ref) => {
const formatValue = (value?: string): string => {
const { minHour, maxHour, minMinute, maxMinute } = props;
Expand Down
18 changes: 8 additions & 10 deletions packages/rc-ui-lib/src/image/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import Icon from '../icon';
import { useSetState, useUpdateEffect } from '../hooks';
import ConfigProviderContext from '../config-provider/ConfigProviderContext';

import type {ReactEventHandler} from "react";

const Image: React.FC<ImageProps> = (props) => {
const { prefixCls, createNamespace } = useContext(ConfigProviderContext);
const [bem] = createNamespace('image', prefixCls);
Expand Down Expand Up @@ -49,18 +51,14 @@ const Image: React.FC<ImageProps> = (props) => {
}
}, [props.src]);

const onLoad = (e) => {
if (!unmountedRef.current) {
setStatus({ loading: false });
props.onLoad?.(e);
}
const onLoad: ReactEventHandler<HTMLImageElement> = (e) => {
setStatus({ loading: false });
props.onLoad?.(e);
};

const onError = (e) => {
if (!unmountedRef.current) {
setStatus({ loading: false, error: true });
props.onError?.(e);
}
const onError: ReactEventHandler<HTMLImageElement> = (e) => {
setStatus({ loading: false, error: true });
props.onError?.(e);
};

const renderLoadingIcon = () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/rc-ui-lib/src/image/PropsType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ export interface ImageProps extends BaseTypeProps {
/** 自元素 */
children?: React.ReactNode;
/** 图片加载完毕时触发 */
onLoad?: (e: React.MouseEvent<HTMLImageElement>) => void;
onLoad?: React.ReactEventHandler<HTMLImageElement>;
/** 图片加载失败时触发 */
onError?: (e: React.MouseEvent<HTMLImageElement>) => void;
onError?: React.ReactEventHandler<HTMLImageElement>;
/** 点击图片时触发 */
onClick?: (e: React.MouseEvent<HTMLImageElement>) => void;
}
2 changes: 1 addition & 1 deletion packages/rc-ui-lib/src/image/demo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default (): React.ReactNode => {
return (
<DemoSection className="demo-image">
<DemoBlock title="基础用法">
<Image width="100" height="100" src={base64} />
<Image width="100" height="100" src={'https://img.yzcdn.cn/vant/cat.jpeg'} />
</DemoBlock>
<DemoBlock title="填充模式">
<Flex wrap="wrap" gutter={20}>
Expand Down