使用 react-native 和 react 导航的元素类型无效错误

时间:2021-05-11 17:08:57

标签: reactjs react-native react-navigation navigation-drawer

我正在使用 react-native 创建一个应用程序,但在使用抽屉导航器时出现错误,我似乎无法找出为什么会出现此错误。

错误是:

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

它与我的抽屉导航有关:

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

但我就是不知道到底是什么问题。

我已经使用文档导入了所有内容,因此一切都是正确的。

这是 MapScreen 常量:

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

DrawerContent 是另一个文件,其中包含抽屉导航器中的所有内容。

有人知道这个错误是什么吗?

1 个答案:

答案 0 :(得分:0)

检查你的@react-navigation/native 和@react-navigation/drawer lib 版本,它们应该有相同的版本

相关问题