Comments (14)
Look at the way you import the component:
import GooglePlacesAutocomplete from 'react-native-google-places-autocomplete';
It should be imported like this
import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';
from react-native-google-places-autocomplete.
Hi @davidgruebl @janroures @GuelorEmanuel
Thanks for your feedback. I promise to look at it this weekend.
Max
from react-native-google-places-autocomplete.
Hm. I just saw in the output that the version of the library is 1.2.2. let me try and downgrade it and I'll come back to you. Thanks.
from react-native-google-places-autocomplete.
experiencing the same issue on react-native 0.31.0
from react-native-google-places-autocomplete.
getting the same on react native 0.23
from react-native-google-places-autocomplete.
@myaskevich in my case it only happens when tapping a list element.
from react-native-google-places-autocomplete.
I just looked at it and here's what I got:
The version 1.2+ of this library requires RN v0.28+. Please check your dependencies once again @davidgruebl . Best way to check RN version is to run RN cli command - react-native --version
.
from react-native-google-places-autocomplete.
@myaskevich
Just checked my version and it's
react-native-cli: 1.0.0
react-native: 0.31.0
from react-native-google-places-autocomplete.
@myaskevich
That actually worked, thanks a lot! If you don't mind can you explain the different between the two syntax, why do we need to wrap the name in curly braces?
from react-native-google-places-autocomplete.
This is a new ES6 feature called destructing. You can read up on this here. See example:
// module1.js
export const foo = () => {
console.log('foo');
};
export const bar = () => {
console.log('bar');
};
// module2.js
// option 1
import module1 from 'module1';
module1.foo() // prints 'foo';
// option2
import { foo } from 'module1';
foo() // prints 'foo';
In order to support the way of importing you proposed, one has to use export default
keyword. See below:
// module1.js
export default const foo = () => {
console.log('foo');
};
// module2.js
import foo from 'module1';
foo(); // prints 'foo'
The reason why we need to do it for now is that because the original library author has put it like this in the first place. I'll probably change it in the future to support that direct import of the component.
from react-native-google-places-autocomplete.
That didn't work for me. Using RN 0.23 and 1.1.9 of this library.
Here is my code:
'use strict';
var React = require('react-native');
import Dimensions from 'Dimensions';
import { eventEmitter } from '../utils/EventEmitter';
import {GOOGLE_GEO_APIKEY} from "../config/constants";
import {GooglePlacesAutocomplete} from 'react-native-google-places-autocomplete';
import I18n from 'react-native-i18n';
var {height, width} = Dimensions.get('window');
var pinX = (width/2) - 22.5;
var MapView = require('react-native-maps');
var {
InteractionManager,
AsyncStorage,
TextInput,
Image,
StyleSheet,
Text,
TouchableOpacity,
View,
ListView,
} = React;
export class SecuritySignupLocationMap extends React.Component {
constructor() {
super();
this.state = Store.getState();
this.state.region = null;
this.onListTap.bind(this);
this.pinY = 0;
}
componentWillMount() {
this.locationSelectedEvent = eventEmitter.addListener('locationSelectedEvent', this.save.bind(this));
this.locationSelectedEventSignup = eventEmitter.addListener('locationSelectedEventSignup', this.saveSignup.bind(this));
if (this.props.type == "signup") {
this.pinY = (height/2) - 67.5;
}else{
this.pinY = (height/2) - 107.5;
}
}
componentDidMount() {
InteractionManager.runAfterInteractions(() => {
this.setState({
region: {
latitude: this.props.latitude,
longitude: this.props.longitude,
latitudeDelta: 0.005,
longitudeDelta: 0.0041
}
});
});
}
componentWillUnmount() {
this.locationSelectedEvent.remove();
this.locationSelectedEventSignup.remove();
}
onRegionChangeComplete(region) {
this.setState({
region: region
});
}
save() {
var location = {
latitude: this.state.region.latitude,
longitude: this.state.region.longitude
}
Actions.fetchAddressForLocation(location);
NavActions.back();
}
saveSignup() {
var location = {
latitude: this.state.region.latitude,
longitude: this.state.region.longitude
}
Actions.fetchAddressForLocation(location);
Actions.back();
}
onListTap(location) {
var longitude = location.geometry.location.lng;
var latitude = location.geometry.location.lat;
var region = {
latitude: latitude,
longitude: longitude,
latitudeDelta: this.state.region.latitudeDelta,
longitudeDelta: this.state.region.longitudeDelta
};
this.refs.map.animateToRegion(region);
this.state.region = region;
}
render() {
if (this.state.region) {
return (
<View ref='view'>
<MapView
ref='map'
style={styles.map}
initialRegion={{
latitude: this.state.region.latitude,
longitude: this.state.region.longitude,
latitudeDelta: this.state.region.latitudeDelta,
longitudeDelta: this.state.region.longitudeDelta
}}
region={this.state.region}
onRegionChangeComplete={this.onRegionChangeComplete.bind(this)}>
</MapView>
<Image
style={[styles.icon, {top: this.pinY}]}
source={require('../images/mapPinIcon.png')}
/>
<GooglePlacesAutocomplete
placeholder={I18n.t('search')}
minLength={2} // minimum length of text to search
autoFocus={false}
fetchDetails={true}
onPress={(data, details = null) => { // 'details' is provided when fetchDetails = true
this.onListTap(details);
}}
getDefaultValue={() => {
return this.props.text; // text input default value
}}
query={{
// available options: https://developers.google.com/places/web-service/autocomplete
key: GOOGLE_GEO_APIKEY,
language: 'es', // language of the results
// types: '(cities)', // default: 'geocode'
}}
styles={{
description: {
fontWeight: 'bold',
},
predefinedPlacesDescription: {
color: '#1faadb',
},
container: {
flex:1,
position:'absolute',
top:0,
left:0,
right:0,
},
textInput: {
flex:1,
flexDirection: 'row',
textAlign:'left',
paddingLeft:10,
paddingRight:10,
marginTop:10,
marginLeft:10,
marginRight: 10,
height:40,
// borderWidth:1,
// borderColor:'transparent',
backgroundColor:'white',
opacity:0.9,
},
textInputContainer:{
backgroundColor: 'transparent',
borderTopWidth: 0,
borderBottomWidth: 0
},
separator:{
height: 0
},
listView: {
backgroundColor:'white',
opacity:0.9,
marginLeft: 10,
marginRight: 10,
}
}}
currentLocation={true} // 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',
}}
filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']} // filter the reverse geocoding results by types - ['locality', 'administrative_area_level_3'] if you want to display only cities
enablePoweredByContainer={false}
/>
</View>
);
}else{
return(<Text>{I18n.t('loading')}</Text>);
}
}
}
Error message: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. Check the render method of StaticRenderer
.
from react-native-google-places-autocomplete.
@janroures Can you capture the output after running npm ls --depth=0
inside your project and paste here as a gist?
from react-native-google-places-autocomplete.
@janroures GOTCHA!
from react-native-google-places-autocomplete.
@myaskevich
Thanks for the detail explanation.
from react-native-google-places-autocomplete.
Related Issues (20)
- Bug Report textInputProps does not take the initial input value HOT 8
- fix for Maximum update depth exceeded Feature Request HOT 3
- Feature Request: onSuccess callback HOT 1
- Bug Report - Debounce is just delaying requests, not really debouncing them HOT 2
- Bug Report
- Bug Report HOT 1
- TypeError: Cannot read property 'getItem' of undefined
- Feature Request - Add GooglePlaceDetail to renderRow HOT 1
- Restricting search to 2+ countries? HOT 1
- Use isFocused method to change state HOT 1
- Unable to Select Addresses from Dropdown in Scrollable Screen HOT 3
- onCleared: Callback after clearing autocomplete
- Close list when clicking outside, and multiple countries
- Feature Request: onClear callback
- Getting an error of XMLHttpRequest while running jest test case HOT 3
- Bug Report HOT 1
- Added placeholderTextColor as prop HOT 1
- Bug Report
- Which Google Places API to use? Places API or Places API (New) ? HOT 5
- Add props for ListFooterComponent of the FlatList
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-google-places-autocomplete.