React-virtualized-scrollToIndex不适用于WindowScroller

问题描述 投票:1回答:1

我正在使用react-virtualized,并尝试使用scrollToIndex功能,但是使用它时出现空白列表。 (如果滚动,则列表再次显示)。

这是我的代码:

        <WindowScroller>
        {({ height, isScrolling, scrollTop }) => (
            <AutoSizer disableHeight>
                {({ width }) => (
                    <List
                        autoHeight
                        height={height}
                        rowCount={lines.length}
                        rowRenderer={({ index, key, style }) => rowRenderer({ index, isScrolling, key, style, lines, onDelete, toggle })}
                        rowHeight={145}
                        scrollTop={scrollTop}
                        scrollToIndex={100}
                        width={width}
                    />
                    )}
            </AutoSizer>
            )}
    </WindowScroller>

如果删除scrollToIndex={100},一切正常。

scrollToIndex是否与WindowScroller兼容?因为我只通过List

找到了它的示例
reactjs react-virtualized
1个回答
5
投票

scrollToIndex是否可以与WindowScroller一起使用?因为我只在List

中找到了它的示例

[不幸的是,当使用WindowScroller时,此功能当前不起作用,因为WS控制滚动位置(而不是List本身)。在同时使用WindowScroller的同时使用scrollToIndex可以使列表发生冲突,并且出现故障。

这个问题之前已经提出过一两次,所以也许这是我最终会尝试支持的问题。

编辑

自版本9.8.0起,WindowScroller支持scrollToIndex属性。

© www.soinside.com 2019 - 2024. All rights reserved.