gpt4 book ai didi

react-native - TypeError : (0, _reactNavigationDrawer.createAppContainer) 不是函数:React Native 错误

转载 作者:行者123 更新时间:2023-12-04 15:27:44 26 4
gpt4 key购买 nike

因此,我尝试编写选项卡导航代码,但在编写 DrawerNavigation.js 时遇到错误。我是 React Native 的程序员,模拟器报错:

enter image description here

这是我的两个文件:

DrawerNavigator.js:

    import * as React from 'react';
import {Platform, Dimensions} from 'react-native';
import {
createDrawerNavigator,
createAppContainer,
} from 'react-navigation-drawer';

import ShopScreen from '../ShopScreen';

const WIDTH = Dimensions.get('window').width;

const DrawerNavigator = createDrawerNavigator(
{
Shop: ShopScreen,
},
{
initialRouteName: 'Shop',
contentOptions: {
activeTintColor: '#e91e63',
},
},
);

export default createAppContainer(DrawerNavigator);


HomeScreen.js:

    import * as React from 'react';
import DrawerNavigator from './navigation/DrawerNavigation';

class HomeScreen extends React.Component {
render() {
return (
<DrawerNavigator />
);
}
}
export default HomeScreen;

如果您对错误有答案或有任何进展,请告诉我。谢谢!

最佳答案

你错误地导入了 createAppContainer,试试这个:

改变

import {createDrawerNavigator, createAppContainer,} from 'react-navigation-drawer';

import { createAppContainer } from 'react-navigation';
import { createDrawerNavigator} from 'react-navigation-drawer';

希望这对您有所帮助!

关于react-native - TypeError : (0, _reactNavigationDrawer.createAppContainer) 不是函数:React Native 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61922141/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com