({ src }: { src: string })
| 24 | } |
| 25 | |
| 26 | export function useImage({ src }: { src: string }): { |
| 27 | src: string | undefined; |
| 28 | isLoading: boolean; |
| 29 | } { |
| 30 | const [loading, setLoading] = React.useState(true); |
| 31 | const [value, setValue] = React.useState<string | undefined>(undefined); |
| 32 | |
| 33 | React.useEffect(() => { |
| 34 | loadImage(src) |
| 35 | .then(() => { |
| 36 | setLoading(false); |
| 37 | setValue(src); |
| 38 | }) |
| 39 | .finally(() => { |
| 40 | setLoading(false); |
| 41 | }); |
| 42 | }, [src]); |
| 43 | |
| 44 | return { isLoading: loading, src: value }; |
| 45 | } |
| 46 | |
| 47 | const ImageComponent = (props: IProps) => { |
| 48 | const { lazy } = props; |
no test coverage detected