react-infinite-scroll-component icon indicating copy to clipboard operation
react-infinite-scroll-component copied to clipboard

How can I change the scrollY when the InfiniteScroll has rendered

Open 17dun opened this issue 1 year ago • 2 comments

in my project I want change the scrollY when user click some button,I tryed change initialScrollY use the useState hooks,but it does not work :(

17dun avatar May 18 '24 13:05 17dun

const [initialScrollY, setInitialScrollY] = useState(0); useEffect(() => { if (searchParams?.get('filter')) { setInitialScrollY(300); } else { setInitialScrollY(0); } }, [searchParams]); <InfiniteScroll initialScrollY={initialScrollY} dataLength={searchList.length} next={getSearchListMore} hasMore={hasMore} loader={<SearchListSkeleton />} hasChildren scrollableTarget="scrollableDiv" className="flex-1 flex-grow overflow-y-scroll no-scrollbar" height="calc(100vh - 96px)" >....</InfiniteScroll>

my code like this

17dun avatar May 18 '24 13:05 17dun

I haven't tried this prop, but we can use ref on the container and do something like ref.current.scrollTop = 0

sapiens-shahbaz-khan avatar Jul 05 '24 10:07 sapiens-shahbaz-khan