bvaughn / react-window

React components for efficiently rendering large lists and tabular data
https://react-window.now.sh/
MIT License
15.48k stars 778 forks source link

Scroll to top gives Invalid onItemsRendered signature #766

Closed killjoy2013 closed 3 weeks ago

killjoy2013 commented 3 weeks ago

using react-window List inside react-window-infinite-loader

I need to scroll the list to top on a button click. I'm getting this error;

Invalid onItemsRendered signature; please refer to InfiniteLoader documentation.

I'm using ref callback like this;

ref={(node) => {
  ref(node);
  listRef.current = node;
}}

How can I sroll to top appropriately?

here is the codesandbox

killjoy2013 commented 3 weeks ago

listRef.current?.scrollToItem(0); did the job 😄