Created
October 29, 2015 16:17
-
-
Save FaridSafi/a6c554328b63743e0255 to your computer and use it in GitHub Desktop.
react-native-google-places-autocomplete-example.js
This file contains 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
/** | |
* Sample React Native App | |
* https://github.com/facebook/react-native | |
*/ | |
'use strict'; | |
var React = require('react-native'); | |
var { | |
AppRegistry, | |
StyleSheet, | |
Text, | |
View, | |
} = React; | |
var GooglePlacesAutocomplete = require('react-native-google-places-autocomplete').create({ | |
placeholder: 'Search', | |
minLength: 2, // minimum length of text to search | |
autoFocus: true, | |
fetchDetails: true, | |
onPress(data, details = null) { // details is provided when fetchDetails = true | |
// console.log(data); | |
// console.log(details); | |
}, | |
getDefaultValue() { | |
return ''; // text input default value | |
}, | |
query: { | |
// available options: https://developers.google.com/places/web-service/autocomplete | |
key: 'API KEY', | |
language: 'en', // language of the results | |
types: '(cities)', // default: 'geocode' | |
}, | |
styles: { | |
description: { | |
fontWeight: 'bold', | |
}, | |
} | |
}); | |
var Example = React.createClass({ | |
render: function() { | |
return ( | |
<GooglePlacesAutocomplete /> | |
); | |
} | |
}); | |
AppRegistry.registerComponent('testgplace', () => Example); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment