Quantcast
Channel: React Native FlatList with columns, Last item width - Stack Overflow
Viewing all articles
Browse latest Browse all 20

Answer by CrackerKSR for React Native FlatList with columns, Last item width

$
0
0

I don't know if it is efficient or not but works like charm.

// I have 4 columnslet rem = column_count - images.length % column_count;let blanks = Array(rem).fill( {} )images.push(blanks);<Flatlist   data={images}   ...  />

// Noteinstead of using {}, you can use {key:value} to handle undesired result by checking these blank item

Here is my actual working code

... let blanks = Array.from({length:4-photos.length%4}).map(i=>({}))  photos.push(blanks)  return ( <View style={styles.container}><FlatList          numColumns={4}          data={photos}...

Screenshot:screenshot of gallary grid view in React native


Viewing all articles
Browse latest Browse all 20

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>