未定义不是函数(在'...(0,_reactNavigation.StackNavigator)...'附近)

问题描述 投票:0回答:1

我正在以本机反应进行研究项目(天气应用)。我正在使用react-navigation v4。它给出了上述错误。请任何人帮助解决此问题。

//Index.js

import React from "react";
import { AppRegistry } from 'react-native';
import App from './App';
import { name as appName } from './app.json';
import { createStore, applyMiddleware } from 'redux';
import reducer from "./reducers";
import { Provider } from 'react-redux';
import thunk from 'redux-thunk';

import { StackNavigator } from 'react-navigation';
import WeatherDetails from './screens/WeatherDetails';
import CityLists from './screens/CityLists';

const Navigation = StackNavigator({
  WeatherDetails: { screen: WeatherDetails },
  CityLists: { screen: CityLists }
});

const store = createStore(reducer, applyMiddleware(thunk));

const wrapper = () => {
  return (
    <Provider store={store}>
      <Navigation />
    </Provider>
  );
}

AppRegistry.registerComponent(appName, () => wrapper);
react-native react-navigation stack-navigator
1个回答
0
投票

react-navigationv(4.0) documentation中所述,您必须单独安装StackNavigator。因此,首先安装StackNavigator

npm install react-navigation-stack --save

然后从createStackNavigator中导入react-navigation-stack

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

现在,创建导航:

const Navigation = createStackNavigator ({
  WeatherDetails: { screen: WeatherDetails },
  CityLists: { screen: CityLists }
});
© www.soinside.com 2019 - 2024. All rights reserved.