I'm working on something like instagram snap scrolling. The User Card should be centered (One card on each scroll).
<FlatList
data={items}
renderItem={({item}) => <UserCardComponent name={item.name} />}
keyExtractor={item => item.id}
snapToAlignment="center"
decelerationRate={'fast'}
snapToInterval={Dimensions.get('window').height}
showsVerticalScrollIndicator={false}
/>
This is working fine after scrolling from the second item onwards or when we touch it, it is adjusting to center but when it is rendered first time its not in the center.
User Card Component looks like this on first render
Second item is perfectly centered, I want first item to be centered.
I tried to move the card upwards using useEffect with these functions scrollToOffset,scrollToItem, scrollToIndex etc. but they needed flatlist reference which is not available while rendering first time.
Thanks in advance. Any help will be appreciated