Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

LazyImage.js

25 lines734 Bytes

1import * as React from 'react';
2import { ProgressiveImage } from './ProgressiveImage';
3import cn from 'classnames';
4export class LazyImage extends React.Component {
5 render() {
6 const {
7 height,
8 width,
9 src,
10 alt,
11 className,
12 style
13 } = this.props;
14 return <ProgressiveImage src={src} placeholder={'data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'}>
15 {({
16 image,
17 isLoading
18 }) => <img className={cn('transition duration-100 ease-in', {
19 'opacity-0': isLoading,
20 'opacity-100': !isLoading
21 }, className)} src={image} alt={alt} width={width} style={style} height={height} />}
22 </ProgressiveImage>;
23 }
24​