[React] Create an Auto Resizing Virtualized List with react-virtualized
2024-08-31 18:24:31
In this lesson we'll show how to use the AutoSizer
component from react-virtualized
to automatically measure the width/height of our content area. We'll then use theList
component to render our set of data as a virtualized list into the DOM using windowing.
Install:
npm install --save react-vistualized
import React, {Component} from 'react';
import {AutoSizer, List} from 'react-virtualized'; const ScreenInfo = ({width, height}) => (<span>width: {width} height: {height}</span>); class App extends Component { renderRow = ({key, isScrolling, style, index}) => {
return (
<div style={style} key={key}>
name: {this.props.data[index].name}
email: {this.props.data[index].email}
</div>
);
}; render() {
return (
<AutoSizer>
{({width, height}) => {
return (
<div>
<ScreenInfo width={width} height={height}/>
<List
rowCount={this.props.data.length}
rowHeight={50}
rowRenderer={this.renderRow}
width={width}
height={height}
/> </div>
);
}}
</AutoSizer>
);
}
} export default App;
最新文章
- nginx配置之取消index.php同时不影响js,css功能
- 学习网页制作中如何在正确选取和使用 CSS 单位
- Subgraph Search Over Large Graph Database
- Linux- Bond
- SQLServer2005:在执行批处理时出现错误。错误消息为: 目录名无效
- Contest1065 - 第四届“图灵杯”NEUQ-ACM程序设计竞赛(个人赛)H吃薯条
- JavaScript中的EcMAScript学习笔记
- Spring读取外部属性-properties
- Selenium中三种等待的使用方式---规避网络延迟、代码不稳定问题
- 【LOJ#6060】Set(线性基)
- DotNet 资源大全中文版
- CentOS_mini下make安装
- maven(九),install安装到本地仓库
- easyui-switchbutton js判断是否启动
- redflag的echarts结构
- Linux下动态链接库加载路径
- window.onbeforeunload() 事件调用ajax
- 第一篇 Python图片处理模块PIL(pillow)
- 网络性能测试工具iperf详细使用图文教程(转)
- 数据结构&;堆&;heap&;priority_queue&;实现