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:
- On load, iterate through dataset for list and calculate height of each row
- Cache calculated data into array or dictionary
- Return cached data inside getItemLayout depend on index
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?