React Native flatlist, unable to load view from the start

115 views Asked by At
                      <FlatList
                        data={data}                        
                        inverted
                        horizontal 
                        renderItem={({ item }) => {

                            if ( item.type == 'video') {
                                return(
                                    <TouchableOpacity style={styles.videoView}>
                                        <View>
                                            <Image 
                                                source={require('./assets/thumbnail.png')}
                                                style={styles.thumbnail}
                                            />
                                            <Text>{item.title}</Text>
                                        </View>
                                    </TouchableOpacity>  
                                );
                            }
                        }}
                        
                      />

The flatlist is getting the from a JSON file from the internet, but when ever I load the app on the phone, the list takes me to the first element of the JSON file(bottom of the list), but I want to see the last element of the JSON file(top of the list) when I load the app.

1

There are 1 answers

1
Erkan GÖRGÜLÜ On

Array.prototype.reverse() could reverse your data then renders it. You can do it before render