gpt4 book ai didi

javascript - react native 导航: Undefined is not a function

转载 作者:行者123 更新时间:2023-12-01 01:39:38 26 4
gpt4 key购买 nike

我最近遇到了 React Native Navigation 的问题,但似乎无法解决。

我正在尝试通过将不同组件的不同堆栈放置在不同文件中来组织堆栈,然后将它们全部放在我在 config/中创建的 router.js 文件中router.js.

我不断收到此错误undefined 不是一个函数(靠近 '...(0, _reactNativeNavigation.createStackManager)...')

我的router.js看起来像这样

import { createBottomTabNavigator } from 'react-navigation';
import Icon from 'react-native-vector-icons/Ionicons';

import { MapStack } from '../components/MapStack';


export const HomeViewTabs = createBottomTabNavigator({
Map: {
screen: MapStack,
navigationOptions: {
tabBarIcon: ({tintColor}) => (
<Icon name="ios-navigate" size={24} color={tintColor}/>
)
}},
}, {
initialRouteName: 'Map',
});

和我导入的MapStack.js

import { createStackNavigator } from 'react-native-navigation';

import Map from '../screens/Map';
import BoxOverview from '../screens/BoxOverview';


export const MapStack = createStackNavigator({
Map: { screen: Map },
BoxOverview: { screen: BoxOverview},
});

我的index.js

import React, { Component } from 'react';
import { HomeViewTabs } from './config/router';


class App extends Component {
render() {
return <HomeViewTabs />;
}
}

export default App;

任何帮助将不胜感激,任何有关我的造型的提示也将不胜感激!

编辑:

为了清晰起见,添加了错误照片

Error

文件结构

app/
+--components/
+----MapStack.js
+--config/
+----router.js
+--screens/
+----Box.js
+----BoxOverview.js

解决方案:

我在 MapStack.js 文件中导入了错误的 React Navigation 模块。它应该是 import { createStackNavigation } from 'react-navigation' 并且我将模块设置为 'react-native-navigation'...

最佳答案

MapStack.js中更改此内容

import { createStackNavigator } from 'react-native-navigation';

至此

import { createStackNavigator } from 'react-navigation';

在我的 friend 指出我导入的模块名称不正确后找到了这个解决方案...

关于javascript - react native 导航: Undefined is not a function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52537752/

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