I saw lots of other questions about this error, and the solution is often a wrong import/export. However, I have been getting this error for a while, and all the imports seem to be correct. How can this problem be fixed?
Error:
Uncaught ErrorElement type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. 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 `Explore`.
Code (following from this tutorial with minor changes):
import { useLocalSearchParams } from "expo-router";import React from 'react';import MapView from 'react-native-maps';import { StyleSheet, View } from 'react-native';export default function Explore() { const params = useLocalSearchParams(); return (<View style={{flex: 1}}><MapView style={{ width: "100%", height: "100%" }} initialRegion={{ latitude: 37.78825, longitude: -122.4324, latitudeDelta: 0.0922, longitudeDelta: 0.0421, }} /></View> );}
Tried reinstalling dependencies and reimporting MapView
(both default and named export).Notably, removing import MapView from 'react-native-maps'
and the MapView
element fixed the problem, so the problem is lying somewhere there.