Skip to content

How can I change the scrollY when the InfiniteScroll has rendered #401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
17dun opened this issue May 18, 2024 · 2 comments
Open

How can I change the scrollY when the InfiniteScroll has rendered #401

17dun opened this issue May 18, 2024 · 2 comments

Comments

@17dun
Copy link

17dun commented May 18, 2024

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
Copy link
Author

17dun commented May 18, 2024

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

@sapiens-shahbaz-khan
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants