scrollToIndex and dynamic size
See original GitHub issueI have a dynamic height list and want to scroll to end https://codesandbox.io/s/exciting-kate-h555x?file=/src/index.js
When I press Scroll To end it sometimes goes to the end and sometime to the Row 9993
Please open the list and press Scroll To end , If you goes to end refresh the page and retry again
Issue Analytics
- State:
- Created 2 years ago
- Comments:13
Top Results From Across the Web
scrollToIndex and dynamic size · Issue #216 · TanStack/virtual
I have a dynamic height list and want to scroll to end https://codesandbox.io/s/exciting-kate-h555x?file=/src/index.js When I press Scroll ...
Read more >Dynamic size item scroll inside FlatList : r/reactnative - Reddit
React Native scrollToIndex - Dynamic size item scroll inside FlatList : r/reactnative.
Read more >Efficient way to scroll to certain index in FlatList with variable ...
My solution was to get each item's size when rendered by using onLayout and map them with their index. I can then use...
Read more >React Native FlatList scrollToIndex with Fixed or Variable Row ...
It is easier to use scrollToIndex with items of a fixed size, but you are not out of luck if your items are...
Read more >Virtualizer | TanStack Table Docs
This function is passed the index of each item and should return the actual size (or estimated size if you will be dynamically...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

It’s definitely a code smell and would not recommend it, but if it solve the issue 99% of times 🙈
Don’t know exactly what is your use case, but there is also an option to pre-render the last
nelements of list, just make it render once before scrolling. It can be done viarangeExtractor, for example pre rendering 25 last items https://codesandbox.io/s/toend-forked-mvow4?file=/src/index.jsI guess the only real way to solve this issue is to use scroll “anchoring” instead of one “scrollToIndex” call. You should maintain scroll position and automatically readjust it in case items or parent container resize. But it is not that easy anyway. Using timeouts or 2+ requestAnimationFrame to wait for something is just unreliable. Some users would report you issues with scroll and you wouldn’t be able to reproduce it.