question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function but got: object

See original GitHub issue

I am getting this error:- Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.

This is my code:–

// @flow ‘use strict’;

import React, { Component } from ‘react’; import { View } from ‘react-native’; import GooglePlacesAutocomplete from ‘react-native-google-places-autocomplete’; import { Actions } from ‘react-native-router-flux’;

// Styles import * as googlePlacesStyle from ‘…/googleplaces/style’;

export default class GooglePlacesScene extends Component {

  state: {
    homePlace?: {
        description: string,
        geometry: {
            location: {
                lat: number,
                lng: number
            }
        }
    },
    workPlace?: {
        description: string,
        geometry: {
            location: {
                lat: number,
                lng: number
            }
        }
    }
};

constructor(props: {}) {
    super(props);

    this.state = {  homePlace: { description: 'Home', geometry: { location: { lat: 48.8152937, lng: 2.4597668 }}},
                    workPlace: {description: 'Work', geometry: { location: { lat: 48.8496818, lng: 2.2940881 } }}};
}

render() {
    return(
     <View style={googlePlacesStyle.bodyStyle}>
         <GooglePlacesAutocomplete
            placeholder='Search'
            minLength={2}
            autoFocus={false}
            fetchDetails={true}
            onPress={(data, details = null) => {
                console.log(data);
                console.log(details);
            }}
            getDefaultValue={() => {
                return ''; // text input default value
            }}
            query={{
                key: 'ALaiPuRiT3eyqE9CDhjjklAD2179Pw1uRoeVfBq',
                language: 'en',
                types: '(cities)',
            }}
            styles={{description: {
                fontWeight: 'bold',
            },
            predefinedPlacesDescription: {
                color: '#1faadb',
            },
        }}
        currentLocation={true}
        currentLocationLabel="Current location"
        nearbyPlacesAPI='GooglePlacesSearch'
        GoogleReverseGeocodingQuery={{
        }}
        GooglePlacesSearchQuery={{
            rankby: 'distance',
            types: 'food',
        }}
        filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']}
        predefinedPlaces={[this.state.homePlace, this.state.workPlace]}
       />

    </View>
    );
}

}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:14

github_iconTop GitHub Comments

10reactions
mayaskcommented, Aug 22, 2016

@GuelorEmanuel

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';
2reactions
mayaskcommented, Aug 19, 2016

Hi @davidgruebl @janroures @GuelorEmanuel

Thanks for your feedback. I promise to look at it this weekend.

Max

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invariant Violation: Element type is invalid: expected a string ...
This error can rise if you try to import a non-existent component. Make sure you have no typo and that the component indeed...
Read more >
Uncaught Invariant Violation: Element type is invalid: expected ...
Uncaught Invariant Violation : Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: ...
Read more >
Element type is invalid: expected a string (for built-in ...
I'm using @wordpress/create-block to create a custom Gutenberg block. When adding the block in Gutenberg, I receive the error: Error: Minified React error...
Read more >
Error Invariant Violation Element type is invalid expected a ...
I am getting this error: Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/ ...
Read more >
Element type is invalid: expected a string (for ... - OneCompiler
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found