javascript Material-UI和React-virtualized
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Material-UI和React-virtualized相关的知识,希望对你有一定的参考价值。
import React, { Component } from 'react';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import FolderIcon from '@material-ui/icons/Folder';
import { AutoSizer, List as VirtualList, CellMeasurer, CellMeasurerCache } from 'react-virtualized';
class MyList extends Component {
cache = new CellMeasurerCache({
fixedWidth: true,
defaultHeight: 90,
});
state = {
items: [...Array(10000)],
};
renderRow = ({ index, parent, key, style }) => (
<CellMeasurer key={key} cache={this.cache} parent={parent} columnIndex={0} rowIndex={index}>
<ListItem style={style} component="div" divider>
<ListItemIcon>
<FolderIcon />
</ListItemIcon>
<ListItemText
primary={`Single-line item: ${index}`}
// secondary={secondary ? 'Secondary text' : null}
/>
</ListItem>
</CellMeasurer>
);
renderList = () => (
<AutoSizer>
{({ width, height }) => (
<VirtualList
ref={(list) => {
this.list = list;
}}
rowCount={this.state.items.length}
width={width}
height={height}
deferredMeasurementCache={this.cache}
rowHeight={this.cache.rowHeight}
rowRenderer={this.renderRow}
overscanRowCount={25}
// ...moarProps
/>
)}
</AutoSizer>
);
render() {
return <List dense={false} component={this.renderList} />;
}
}
export default MyList;
以上是关于javascript Material-UI和React-virtualized的主要内容,如果未能解决你的问题,请参考以下文章
javascript React Material-UI Carousel
无法在 React Material-UI 中的 useState 中设置值
更改material-ui对话框显示的动画
ReactJS + Material-UI:如何在每个 TableRow 中使用 Material-UI 的 FlatButton 和 Dialog?
Formik 和 Material-UI
如何连接 Algolia 和 @material-ui