pranami
pranami

Reputation: 1415

How to render a function inside a FlatList for a specific element in React Native

I have a FlatList component as shown below :

I have a section inside the SelectableChip component :

So, on navigating to the Detail page, I want to show the details of the particular item that was clicked.But what is happening now is, it is iterating through all the data and going to the last item and showing the last item details, not the one I clicked.

Can someone please help me on how to fix this?

EDIT

JSON data:

export const planDetails = [

    { 
        "nbs_plans":[ 
           
           { 
              "productId":"11",
              "sku":"6561",
              "name":"TruHealth Lawn Plan",
              "description":"Get out and enjoy the greenest, healthiest lawn possible with this comprehensive plan, which provides essential nutrients, protection, organic soil amendments and lawn aeration.",
    
    

Upvotes: 0

Views: 300

Answers (1)

Zeeshan Ansari
Zeeshan Ansari

Reputation: 10838

Use

onPress={() => this.gotoDetailsPage(item.extension_attributes, index)}

Instead of

onPress = {this.gotoDetailsPage(item.extension_attributes, index)}

Upvotes: 1

Related Questions