React-virtualized - scrollToIndex 不适用于 WindowScroller

React-virtualized - scrollToIndex doesn't work with WindowScroller

我正在使用 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

的例子

Does scrollToIndex works with WindowScroller? because I only found example of it with List

不幸的是,此功能目前在使用 WindowScroller 时不起作用,因为 WS 控制滚动位置(而不是列表本身)。在同时使用 WindowScroller 的同时使用 scrollToIndex 会给出 List 冲突的信息和问题。

这个问题以前出现过一两次,所以也许我最终会尝试支持它。

编辑

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