Alex Proshkin
Alex Proshkin

Reputation: 127

How to pass in navigation props into a functional component screen through React Navigation?

I have a functional component screen with a React Native FlatList of custom "Tasks". I want to be able to navigate from a task to another functional component, "TaskEditScreen" and pass some props to the screen as well.

<TouchableOpacity onPress={()=>{navigation.navigate('Task Edit')}}>
   <Feather
      name="edit"
      size={35}
      color="black"
      style={{
         margin: 5
      }}    
   />
</TouchableOpacity>

The onPress function works and it navigates me to the correct screen, but how do I also pass in some kind of props or data to this screen?

Upvotes: 0

Views: 1309

Answers (1)

95faf8e76605e973
95faf8e76605e973

Reputation: 14191

Documentation: https://reactnavigation.org/docs/params

<TouchableOpacity onPress={() => { navigation.navigate('Task Edit', {someParam: "someValue"}) }}>
  <Feather
    name="edit"
    size={35}
    color="black"
    style={{
      margin: 5
    }}
  />
</TouchableOpacity>

Upvotes: 3

Related Questions