【发布时间】:2021-01-26 01:33:31
【问题描述】:
我正在尝试使用 createStackNavigator 实现基本的堆栈导航:
App.js
import { createStackNavigator } from '@react-navigation/stack';
const Stack = createStackNavigator();
function MyStack() {
return (
<Stack.Navigator>
<Stack.Screen name="Home" component={Home} />
<Stack.Screen name="Notifications" component={Notifications} />
<Stack.Screen name="Profile" component={Profile} />
<Stack.Screen name="Settings" component={Settings} />
</Stack.Navigator>
);
}
当我在我的 Mac (Big Sur) 上运行此程序时,我在 Metro 控制台中收到此错误:
[Mon Jan 25 2021 19:21:42.268] BUNDLE ./index.js
[Mon Jan 25 2021 19:21:44.595] ERROR TypeError: null is not an object (evaluating '_RNGestureHandlerModule.default.Direction')
[Mon Jan 25 2021 19:21:44.596] ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
[Mon Jan 25 2021 19:21:45.600] ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
这是我的 package.json:
{
"name": "stack_navigation",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@react-navigation/stack": "^5.14.2",
"react": "16.13.1",
"react-native": "0.63.4"
},
"devDependencies": {
"@babel/core": "7.12.10",
"@babel/runtime": "7.12.5",
"@react-native-community/eslint-config": "1.1.0",
"babel-jest": "25.5.1",
"eslint": "6.8.0",
"jest": "25.5.4",
"metro-react-native-babel-preset": "0.59.0",
"react-test-renderer": "16.13.1"
},
"jest": {
"preset": "react-native"
}
}
我有什么办法可以在不崩溃的情况下使用 createStackNavigator 吗?
【问题讨论】:
标签: react-native react-native-ios react-native-navigation