【发布时间】:2019-10-03 09:01:00
【问题描述】:
我正在我的项目中设置一个反应虚拟化的无限加载器,但我有一个小问题。所以我没有 remoteRowCount 所以我找到了一个解决方案,像这样:
public rowCount = this.props.hasNextPage ? this.props.list.length + 1 : this.props.list.length;
但这对我不起作用。我试图调试为什么不工作,但我什么也没找到。
p
public rowCount = this.props.hasNextPage ? this.props.list.length + 1 : this.props.list.length;
<InfiniteLoader
rowCount={this.rowCount}
isRowLoaded={({ index }) => !!this.props.list[index]}
loadMoreRows={this.props.loadMoreRows}
minimumBatchSize={10}
threshold={5}
>
{({ onRowsRendered, registerChild }) => (
<WindowScroller>
{({ height, isScrolling, onChildScroll, scrollTop }) => (
<AutoSizer disableHeight>
{({ width }) => (
<List
ref={list => {
this.listRef = list;
registerChild(list);
}}
onRowsRendered={onRowsRendered}
autoHeight
width={width}
height={height}
rowCount={this.props.list.length}
rowHeight={56}
rowRenderer={this.rowRenderer}
overscanRowCount={0}
isScrolling={isScrolling}
onScroll={onChildScroll}
scrollTop={scrollTop}
/>
)}
</AutoSizer>
)}
</WindowScroller>
)}
</InfiniteLoader>
【问题讨论】:
-
能否请您在 codepen 中创建一个最小可重现的示例?
标签: javascript reactjs typescript react-virtualized rowcount