Skip to content

Instantly share code, notes, and snippets.

@hanipcode
Created September 30, 2017 09:02
Show Gist options
  • Select an option

  • Save hanipcode/79c6d545d5ca586828604e29df87d832 to your computer and use it in GitHub Desktop.

Select an option

Save hanipcode/79c6d545d5ca586828604e29df87d832 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import {
View,
Text,
FlatList,
StyleSheet,
TouchableHighlight
} from 'react-native';
// .. rest of code
class AutoCompleteResultList extends Component {
// .. rest of code
renderItem({ item }) {
return (
<TouchableHighlight
underlayColor="#dddddd"
onPress={() => this._onItemClick(item.geometry)}
>
<View style={styles.AutoCompleteResultItem}>
<Text style={styles.titleText}>{item.name}</Text>
<Text style={styles.text}>{item.formatted_address}</Text>
</View>
</TouchableHighlight>
);
}
_onItemClick(geometry) {
this.props.onItemClick(geometry);
}
// .. rest of code
render() {
return (
<View>
{this.props.data.length > 0 && (
<FlatList
{...this.props}
contentContainerStyle={styles.AutoCompleteResultList}
renderItem={itemValue => this.renderItem(itemValue)}
/>
)}
</View>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment