Created
September 26, 2017 14:09
-
-
Save hanipcode/72def571310e1f5dea8141f86646d435 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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