Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

React Native FLatList render some of items

i send the data from the backen and want to show some of the items on the flatlist the flatlist render all the data i want to render the latest 3 items

FlatList

   <FlatList 
    data={props.data}
    disableVirtualization={false}
    keyExtractor={item => item.key}
    snapToInterval={90}
    decelerationRate='fast'
    renderItem={({item}) =>{
     return(
         <View style={{height: 100, width: 350}}>
         <View style={globalStyles.transactionContainer}>
          <Text style={globalText.h3}>{item.type}</Text>
          <Text style={globalText.h3}>{item.amount}</Text>
        </View>
      
      </View>
     )}}
   />
   
  </View>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

try this:

<FlatList 
    data={props.data.slice(0, 3)}
    inverted
    disableVirtualization={false}
    keyExtractor={item => item.key}
    snapToInterval={90}
    decelerationRate='fast'
    renderItem={({item}) =>{
     return(
         <View style={{height: 100, width: 350}}>
         <View style={globalStyles.transactionContainer}>
          <Text style={globalText.h3}>{item.type}</Text>
          <Text style={globalText.h3}>{item.amount}</Text>
        </View>
      
      </View>
     )}}
   />

I add inverted prop and add a slice on you data

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading