Customizable Google Places autocomplete component for iOS and Android React Native apps
How many times, as a Web developer, you pointed to Google Places API Javascript docs and installed (updated?) it.
How weird did it look on your Mobile devices?
Oh, maybe you're a iOS or Android developer.
Have you ever wished it just was one npm install
away?
We're in React Native's heavens now, meet Farid Safi and its cross platform Component for Google Places autocomplete.
react-native-google-places-autocomplete
Customizable Google Places autocomplete component for iOS and Android React-Native apps
Features
- Places autocompletion
- iOS and Android compatibility
- Places details fetching + ActivityIndicatorIOS/ProgressBarAndroid loaders
- Customizable using the styles parameter
- XHR cancellations when typing fast
- Google Places terms compliant
- Caching of results
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);
},
query: {
// available options: https://developers.google.com/places/web-service/autocomplete
key: "YOUR API KEY",
language: "en", // language of the results
types: "(cities)", // default: 'geocode'
},
styles: {
description: {
fontWeight: "bold",
},
},
});