react-native-google-places-autocomplete: Autocomplete not working after upgrade to React Native 0.38
Hi guys, This component stopped working on our app after we upgraded to React Native 0.38. Nothing else is changed. Is there any new setting we need to cater for after upgrade? Here’s our code if it helps, pretty standard:
import React, {Component} from 'react';
import {View, MapView, WebView, Text} from 'react-native'
//import WebViewBridge from 'react-native-webview-bridge';
var {GooglePlacesAutocomplete} = require('react-native-google-places-autocomplete');
const injectScript = `
(function () {
if (WebViewBridge) {
WebViewBridge.onMessage = function (message) {
};
}
}());
`;
var self;
class LocationSearch extends Component {
constructor(props) {
super(props);
}
componentDidMount() {
self = this;
}
render() {
var route = this.props.navigator.getCurrentRoutes(0);
searchlocation = route[route.length - 1].positionToSearch;
var stringSearchLocation= searchlocation.coords.latitude +', ' + searchlocation.coords.longitude;
return (
<View style={{marginTop:60}}>
<GooglePlacesAutocomplete
placeholder='Search'
minLength={2}
autoFocus={false}
fetchDetails={true}
onPress={(data, details = null) => {
self.props.callBack(details);
self.props.navigator.pop();
} }
query={{
// available options: https://developers.google.com/places/web-service/autocomplete
key: 'AIzaSyCJzwLTQ4ADlEr2vftLexbX2xY81hO9yq0',
language: 'en', // language of the results
location: stringSearchLocation,
radius:5000
}}
styles={{
description: {
fontWeight: 'bold',
},
predefinedPlacesDescription: {
color: '#1faadb',
},
}}
currentLocation={false} // Will add a 'Current location' button at the top of the predefined places list
currentLocationLabel="Current location"
nearbyPlacesAPI='GooglePlacesSearch' // Which API to use: GoogleReverseGeocoding or GooglePlacesSearch
GoogleReverseGeocodingQuery={{
// available options for GoogleReverseGeocoding API : https://developers.google.com/maps/documentation/geocoding/intro
}}
GooglePlacesSearchQuery={{
// available options for GooglePlacesSearch API : https://developers.google.com/places/web-service/search
rankby: 'distance',
types: 'food',
}}
filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']}
/>
</View>
);
}
}
module.exports = LocationSearch;
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 27
@saeed2402 this is how I used the style, let me know if this helps. Also my
onPress
gets called as well!playing around with this property revealed the list for me, whoooot looks like some styling errors in the module
@saeed2402 @LoriKarikari
Hi guys, could you please point me out what I am doing wrong? My
onPress
handler is not being called. I don’t get anydata
nordetails
. Literally nothing. Thank you in advance!Here is my code:
Dependencies:
Thanks a lot for your help @jnrepo again, really appreciate it.