I need set initialScrollIndex
on FlatList to 1, so second row will be visible on initial loading. It's depend on getItemLayout
.
My FlatList cells contains text of different length, which leads to different height of each cell, which leads i can not return fixed value in getItemLayout
.
My strategy is:
The problem is - i can not find the way how to calculate the height of an view before it will be mounted into DOM hierarchy. I read a lot about onLayout prop, but it looks like View
should be rendered first to get it to work.
So, what do you use to achieve scrolling to specified row in react-native when list cell is not the same for each row?
My first thought - try render it hidden, take size and make it visible.
EDIT: You also can try use react-native-text-size to calculate cell heights manually.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With