1
votes

I'm working with react-virtualized, and trying to use the scrollToIndex feature, but I get an empty list when using it. (If I scroll, then my list show again).

Here is my code:

        <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>

If I remove scrollToIndex={100}, everything works fine.

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

1

1 Answers

5
votes

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

Unfortunately this feature does not currently work when WindowScroller is being used because WS controls the scroll position (not the List itself). Using scrollToIndex while also using WindowScroller gives the List conflicting information and things break.

This is a question that has come up once or twice before so maybe it's something I will try to support eventually though.

EDIT

Since version 9.8.0, WindowScroller supports scrollToIndex prop.