我已经在项目文件夹中安装了react-navigation
模块:
〜/react-tutorial/react-native/project1 $ npm安装 - 保存react-navigation
npm警告可选跳过可选依赖性:fsevents@1.2.7(node_modules/fsevents):
npm警告notsup跳过可选依赖性:fsevents@1.2.7的未支撑平台:想要{" os":" darwin"," arch":"任何" and"}(当前:{" os":{" os":" Linux","Arch":" x64"})
- react-navigation@3.3.3.2 在43.188S中添加了10个贡献者的22个包裹,并审核了103279个包裹 发现11个低严重性脆弱性 运行
npm audit fix
修复它们,或为详细信息进行npm audit
但是,当我尝试将StackNavigator
包含在import { StackNavigator } from 'react-navigation';
在调试远程时,我在浏览器中有以下错误
typeerror:bundle.modules不确定
在新的react-native
版本中,react-navigation
中有更改。 StackNavigator
已被createStackNavigator
替换。
您必须与react-navigation.
(下面的命令)一起安装react-native-gesture-handler
npm install --save react-native-gesture-handler // install
react-native link react-native-gesture-handler // link
我将帮助下面的一些语法
old version below -
import { StackNavigator } from 'react-navigation';
const PrimaryNav = StackNavigator({
Splash: { screen: Splash },
Login: { screen: Login },
}, {
// Default config for all screens
headerMode: 'none',
initialRouteName: 'Splash',
});
New Version below -
import { createAppContainer, createStackNavigator } from 'react-navigation';
const MainNavigator = createStackNavigator({
Splash: { screen: Splash }
},
{
// Default config for all screens
headerMode: 'none',
initialRouteName: 'Splash'
});
const PrimaryNav = createAppContainer(MainNavigator);