DeJavu
DeJavu

Reputation: 73

React Native List View TouchableHighlight

I am having an issue with ListView and TouchableHighlight I followed this tutorial https://rnplay.org/apps/M4tiAQ Everything is perfect. My problem is when I try to select row data of list view. It doesnt give me anything. I want to change the scene, while selecting row data. Here is sample of what I did in renderAdress function

      renderAdress = (adress) => {
    return (
<TouchableHighlight  onPress = { this._onPressAddressList(rowData)} underlayColor = 'white' >
      <View>
        <Text>{adress.street}, {adress.city}, {adress.country}</Text>
      </View>
</TouchableHighlight>
    );
  };

What I want is whenever user selects one of the row data from list, the scene changes and row value is passed to other scene. I really appreciate the help. Thanks

Upvotes: 2

Views: 2789

Answers (1)

Safeer Hussain
Safeer Hussain

Reputation: 1340

It seems the problem with onPress function. Try changing it to onPress = { this._onPressAddressList.bind(this, rowData)}

      renderAdress = (adress) => {
    return (
<TouchableHighlight  onPress = { this._onPressAddressList.bind(this, rowData)} underlayColor = 'white' >
      <View>
        <Text>{adress.street}, {adress.city}, {adress.country}</Text>
      </View>
</TouchableHighlight>
    );
  };

Upvotes: 2

Related Questions