Quantcast
Channel: How to sort list of objects within renerItem of flatlist? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

How to sort list of objects within renerItem of flatlist?

$
0
0

Hello I want to sort an object within renderItem of FlatList.I'm getting array of objects as server response.I want to do sorting within these objects.I've a list of cars with their price. If the user click on sort button of car with lowest price first.I want to show the cars with lowest price first in the list.The structure of item within renderItem is as follows.

enter image description here

The expanded structure of single item is as follows.I want to sort the object by its priceTotal.

enter image description here

Following is my code which I've done so far.Please help to find a solution.

sample code

 renderItems = ({ item, index }) => {
    return (
          <CarReservationDetailComponent
            carName={item.make}
            carType={item.carType}
            carPrice1={item.priceTotal}
            mileage
            mileageText={item.autonomy + 'km. restantes'}
            imageUri={item.picture}
          />
        )
      }
    .....
    <FlatList
                  data={this.props.value.value}
                  renderItem={this.renderItems}
                  ItemSeparatorComponent={this.renderSeparator}
                  showsVerticalScrollIndicator={false}
                />

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images