React Grid Gallery滚动上的延迟加载

时间:2019-12-15 23:18:59

标签: javascript reactjs

我正在使用React网格库(https://github.com/benhowell/react-grid-gallery)来显示图像,但是不能以滚动用户的身份延迟加载页面。

                  <Gallery
                    images={this.props.newExamples}
                    enableImageSelection
                    thumbnailImageComponent={ImageComponent}
                    rowHeight={this.props.newExamples[0].thumbnailHeight}
                    margin={10}
                    onSelectImage={(index, image) => this.onSelectImageNewExample(index, image)}
                  />

1 个答案:

答案 0 :(得分:1)

我在thumbnailImageComponent中使用了react-lazy-load-image-component,像这样:

    class ImageComponent extends React.Component {
    constructor(props) {
        super(props);
    }
    render () {
        console.log(this.props.imageProps)
        return (
                <LazyLoadImage
                    height={this.props.imageProps.style.width}
                    width={this.props.imageProps.style.width} 
                    src={this.props.imageProps.src} 
                    />
        );
    }
}
相关问题