Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

assigning ID to view react native

renderRow(rowData, sectionID, rowID){
  var past_matches_circles =[];
  for(var i=0; i<isPast; i++){
    past_matches_circles.push(
      <TouchableOpacity id={i} key = {i} collapsable={false} style={styles.small_circle} onPress={()=>this.pressOnCircle(rowData[`${i}`].MatchID)}>
      </TouchableOpacity>
    );
  } 
  return (
    <View>
      <View style={{flexDirection:'row'}}>
        {past_matches_circles}
      </View>
      <View style={{flexDirection:'row'}}>
        <Image style={{width:100, height:100, margin:5}} source={{uri:'http://facebook.github.io/react/img/logo_og.png'}}/>
        <View style={{justifyContent:'center', flex:1}}>
          <Text> {rowData[0].MatchDate} </Text>
          <Text> {rowData[0].HomeTeam} VS {rowData[0].AwayTeam} </Text>
        </View>
      </View>
    </View>
  );
}
pressOnCircle(i){
  ToastAndroid.show('key ' + i, ToastAndroid.SHORT);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #assigning #ID #view #react #native
ADD COMMENT
Topic
Name
5+7 =