Search code examples
react-nativereact-native-flatlistflatlist

Retrieve data from screen to screen in react native


Im sending the data "item.email" from screen X to screen HomeParent How can I retrieve the data in the HomeParent screen?

  renderItem=(item,index)=>{
    return(
       <View style={styles.listItemContainer}>
          <TouchableOpacity onPress={()=>this.props.navigation.navigate("HomeParent",item.email)}>
            <View style={styles.listItemTitleContainer}>
              <Text>Hello</Text>
            </View>
          </TouchableOpacity>
        </View>
    )
  }

Solution

  • Pass it as a object field

    <TouchableOpacity onPress={()=>this.props.navigation.navigate("HomeParent",{mail:item.email})}>
    

    and use getParam like this,

    const email = this.props.navigation.getParam('mail')