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.

Element type is invalid

See original GitHub issue

Everything was working fine, but now I’m getting this error when I try to type input. Also getting a warning about getInitialState which is in the package code.

screen shot 2017-09-21 at 1 52 30 pm


import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';

<GooglePlacesAutocomplete
          placeholder={'search'}
          minLength={2}
          autoFocus={false}
          returnKeyType={'search'}
          fetchDetails={true}
          onPress={(data, details) => {
            const lat = details.geometry.location.lat;
            const lng = details.geometry.location.lng;
            const coords = {
              lat: lat,
              lng: lng
            };
            this.setState({ lat: lat, lng: lng });
          }}
          query={{
            key: private,
            language: 'en',
          }}
          GooglePlacesSearchQuery={{
            rankby: 'distance',
            types: 'geocode'
           }}
          filterReverseGeocodingByTypes={['locality', 'administrative_area_level_3']}
          debounce={200}
          keyboardShouldPersistTaps="always"
          renderLeftButton={() => <Image source={search} />}
          styles={{
            textInputContainer: {
              height: 40,
              backgroundColor: '#181818',
              borderTopWidth: 0,
              marginLeft: 10,
              marginRight: 10,
              alignItems: 'center'
            },
            description: {
              color: 'white'
            },
            textInput: {
              height: 40,
              color: '#E1E1E5',
              paddingBottom: 15,
              backgroundColor: 'transparent',
              borderBottomWidth: 1,
              borderBottomColor: 'grey',
              // color: '#5d5d5d',
              fontSize: 16
            },
            poweredContainer: {
              backgroundColor: 'transparent'
            }
          }}
        />

Im using RN 0.42

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

1reaction
mbelgradercommented, Oct 5, 2017

I have a comma there, i just deleted when deleting the key to copy paste.

Downgrading to 1.2.12 worked for me, but I’d like to use the newer version if possible.

1reaction
GregTheGreekcommented, Sep 29, 2017

@mbelgrader your are missing a comma.

            key: private
            language: 'en',
          }}
            key: private,       // Forgot comma
            language: 'en',
          }}

Edit: I now face your issue of the typing in the input, but the missing comma was an issue. I also receive an issue about getInitialState

import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';
....
{Code from above}

package.json

    "react": "~15.4.0-rc.4",
    "react-native": "0.41.1",
    "react-native-google-places-autocomplete": "^1.3.6",

EDIT#2

peer dependency issue on my end. downgraded to 1.2.12 and works

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 >
(React) Element type is invalid, expected a string (for built in ...
To solve the error "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 ... - GitHub
The app breaks and gives this error message: Element type is invalid: expected a string (for built-in components) or a class/function (for ...
Read more >
Element type is invalid: expected a string (for built-in ... - Reddit
Getting Error: 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 ... - 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