Navigation to another screen with data fetched in FlatList

58 views Asked by At

I am trying to navigate to another screen with the value which I fetched in my FlatList.

Just for example :

renderItem={({item}) =>(
     <Text style={styles.FlatListItemStyle} 
        onPress={() => {props.navigation.navigate('AnotherScreen', {item: item.Value1})}} > ID : {item.Value1}
    </Text>
})

here is navigation js.

<Stack.Screen
      name='OneScreen'
      component={OneScreen}
      options={({ route }) => ({
              title: route.params.item.Value1
            })}
/>

so I want to navigate to another screen which uses Value1 as an argument.

but I am getting undefined.

Please help me.

1

There are 1 answers

2
Guruparan Giritharan On BEST ANSWER

It should be item not item.value

<Stack.Screen
      name='OneScreen'
      component={OneScreen}
      options={({ route }) => ({
              title: route.params.item
            })}
      />

You are passing the prop {item:item.value1} so the prop is item thats why you are getting undefined