NielsNL4
NielsNL4

Reputation: 640

Element type is invalid error using react-native and react navigation

I am creating an app in react-native and I have an error while using the drawer navigator and I can't seem to find out why this error is here.

the error is:

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 `DrawerView`. 

it has something to do with the drawer navigation I have:

const AppStack = () => {
  return (
    <Drawer.Navigator drawerContent={(props) => <DrawerContent {... props} /> } >
        <Drawer.Screen name="Map" component={MapScreen} />
    </Drawer.Navigator>
  );
}

but I just can't find out what exactly the problem is.

I have imported everything using the documentation so that is all correct.

This is the MapScreen Const:

const MapScreen = ({ navigation }) => {
    return(
      <>
        <Map/>
        <TouchableOpacity onPress={() => navigation.openDrawer()} style={styles.drawerButton}/>
        <View style={styles.mapDrawerOverlay} />
      </>
    );
  };

and the DrawerContent is another file with everything inside the drawer navigator.

is there anyone who knows what this error can be?

Upvotes: 4

Views: 851

Answers (1)

Shirin
Shirin

Reputation: 118

Check your @react-navigation/native and @react-navigation/drawer lib version they should have same version

Upvotes: 2

Related Questions