Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FaridSafi/a6c554328b63743e0255 to your computer and use it in GitHub Desktop.
Save FaridSafi/a6c554328b63743e0255 to your computer and use it in GitHub Desktop.
react-native-google-places-autocomplete-example.js
/**
* 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