Skip to content

Instantly share code, notes, and snippets.

@hanipcode
Created September 26, 2017 14:09
Show Gist options
  • Select an option

  • Save hanipcode/72def571310e1f5dea8141f86646d435 to your computer and use it in GitHub Desktop.

Select an option

Save hanipcode/72def571310e1f5dea8141f86646d435 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import AutoCompleteBox from '../components/AutoCompleteBox';
import AutoCompleteResultList from '../components/AutoCompleteResultList';
import { getPredictionWithDetail } from '../services.js';
const KEY = 'Your_API_KEY';
class SearchPage extends Component {
constructor(props) {
super(props);
this.state = {
query: '',
data: []
};
}
onChangeText(query) {
this.setState({ query });
getPredictionWithDetail(query, KEY).then(result => {
this.setState({ data: result });
});
}
render() {
return (
<View>
<AutoCompleteBox
placeholder="Masukan Nama Tempat"
value={this.state.query}
onChangeText={query => this.onChangeText(query)}
/>
<AutoCompleteResultList data={this.state.data} />
</View>
);
}
}
export default SearchPage;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment