'Google API - Places autocomplete in React Native Expo Project
I am developing mobile app using React Native Expo. I am using react-native-google-places-autocomplete
for text auto completetion of location/places. It is Google API. I have made account, enabled the google service and also added my billing info. But the code is not working .
See the code below:
<View style={{height: 500}}>
<GooglePlacesAutocomplete
fetchDetails={true}
placeholder='Search'
onPress={(data, details = null) => {
console.log(data, details);
}}
query={{
key: 'my-api-key-here',
language: 'en',
}}
/>
</View>
I am able to SUCCESSFULLY see the Search
placeholder where I can type, but I am not able to see the suggestions/autocompletion text by google. I am able to type the location successfully in the box, but there is no location suggestions coming by google.
I have installed and imported relevant libraries too.
Solution 1:[1]
You need to add prop listViewDisplayed={boolean or "auto"}. See this link https://snack.expo.io/@tobzy/react-native-google-places-autocomplete-example
Solution 2:[2]
Had this happen to me too. Just had to add flex: 1
to my View as I didn't provide any height styling like OP.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Lazar Spasic |
Solution 2 | Ryan Soderberg |