-
Hi everyone, I'm using useInfiniteQuery to handle an infinite scroll list. When I change the key to update the list with differents data, it goes directly to the last view page due to scroll restoration. Is there a way to disable this ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
react-query doesn't actively do something with scroll restoration - the browser does that :) If you change the key and have no data, you will be in loading state. If you change the key and already have data, the data from the cache will be returned. if you are on page 3, and you change the key, and you also get 3 pages for the new key from the cache, your scroll position will stay where it is. Is that what you mean? If so, I think you'd need a |
Beta Was this translation helpful? Give feedback.
react-query doesn't actively do something with scroll restoration - the browser does that :) If you change the key and have no data, you will be in loading state. If you change the key and already have data, the data from the cache will be returned. if you are on page 3, and you change the key, and you also get 3 pages for the new key from the cache, your scroll position will stay where it is. Is that what you mean? If so, I think you'd need a
useEffect
that scrolls to the top whenever the key changes