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.

`Error: Element type is invalid` with react-native-maps v1.0.0

See original GitHub issue

After updating to v1.0.0 of react-native maps I got the following error:

 ERROR  Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check the render method of `MapViewDirections`.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
ptreitlercommented, Jul 11, 2022

Seems to be a change with the exports of react-native-maps. Here’s a patch that fixes the error for me:

diff --git a/node_modules/react-native-maps-directions/src/MapViewDirections.js b/node_modules/react-native-maps-directions/src/MapViewDirections.js
index ac08d73..f04ef10 100644
--- a/node_modules/react-native-maps-directions/src/MapViewDirections.js
+++ b/node_modules/react-native-maps-directions/src/MapViewDirections.js
@@ -1,6 +1,6 @@
 import React, { Component } from 'react';
 import PropTypes from 'prop-types';
-import MapView from 'react-native-maps';
+import { Polyline } from 'react-native-maps';
 import isEqual from 'lodash.isequal';
 
 const WAYPOINT_LIMIT = 10;
@@ -305,7 +305,7 @@ class MapViewDirections extends Component {
 		} = this.props;
 
 		return (
-			<MapView.Polyline coordinates={coordinates} {...props} />
+			<Polyline coordinates={coordinates} {...props} />
 		);
 	}
2reactions
bramuscommented, Jul 28, 2022

Released as 1.9.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Element type is invalid . React Native - Stack Overflow
As you said, this is a common error you can see while developing with React Native. It occurs when the component name is...
Read more >
error-element-type-is-invalid-expected-a-string-for-built-in ...
Unable to open 'App.js': Cannot read property 'parentNode' of undefined.
Read more >
Element type is invalid: expected a string (for ... - OneCompiler
Getting following error after migrating to material-ui 1.0. Element type is invalid: expected a string (for built-in components) or a class/function (for ...
Read more >
Export default class app extends component error - Weebly
Type a JavaScript function to find the difference for two arrays. ... atom javascript es6 linter AttachConsole failed with error 6 : Invalid...
Read more >
react-native-router-flux | Yarn - Package Manager
v4.0.0-beta.x is based on React Navigation v1.5.x. ... for Share application #2338; Example project error #2337; Element type is invalid: expected a string....
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