我在react-native中收到“对象不起作用(评估为0,reactNavigation.default)”错误。
下面是我的App.js文件
import Login from "./Login/Login.js";
import Home from "./Login/Home.js";
import createStackNavigator from "react-navigation";
const App = createStackNavigator({
LoginScreen: {screen: Login},
HomeScreen: {screen: Home},
});
export default App
下面是我的index.js文件
import React, { Component } from 'react';
import {AppRegistry} from 'react-native';
import App from './src/components/App';
import {name as appName} from './app.json';
AppRegistry.registerComponent(appName, () => App);
任何人都可以帮助我解决此问题,因为我不知道为什么会出现此错误
提前谢谢!
答案 0 :(得分:0)
如果您使用的是react-navigation
v2,则应执行以下操作
import Login from "./Login/Login.js";
import Home from "./Login/Home.js";
import {createStackNavigator} from "react-navigation";
const App = createStackNavigator({
LoginScreen: {screen: Login},
HomeScreen: {screen: Home},
});
export default App
如果您使用的是react-navigation
v3,则应执行以下操作,因为此版本中引入了重大更改
import Login from "./Login/Login.js";
import Home from "./Login/Home.js";
import {createStackNavigator, createAppContainer} from "react-navigation";
const Stack = createStackNavigator({
LoginScreen: {screen: Login},
HomeScreen: {screen: Home},
});
const App = createAppContainer(Stack);
export default App