英文:
React Native Drawer Navigation v6.6.2 Issue with React Native Reanimated v3.2.0
问题
我已成功安装了ReactNative抽屉导航,但它只能工作一次。从一开始,汉堡菜单不起作用,但我可以滑出抽屉,当我按下任何导航项时,它会将我带到该屏幕。但之后它停止工作了。
我按照官方指南操作:https://reactnavigation.org/docs/drawer-navigator#installation
请帮助!!!
这是我的package.json
{
"name": "AwesomeProject",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"lint": "eslint .",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"@react-navigation/drawer": "^6.6.2",
"@react-navigation/native": "^6.1.6",
"react": "18.2.0",
"react-native": "0.71.8",
"react-native-gesture-handler": "^2.10.2",
"react-native-reanimated": "^3.2.0",
"react-native-safe-area-context": "^4.5.3",
"react-native-screens": "^3.20.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native-community/eslint-config": "^3.2.0",
"@tsconfig/react-native": "^2.0.2",
"@types/jest": "^29.2.1",
"@types/react": "^18.0.24",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.2.1",
"eslint": "^8.19.0",
"jest": "^29.2.1",
"metro-react-native-babel-preset": "0.73.9",
"prettier": "^2.4.1",
"react-test-renderer": "18.2.0",
"typescript": "4.8.4"
},
"jest": {
"preset": "react-native"
}
}
这是index.js,入口文件:
/**
* @format
*/
import { AppRegistry } from 'react-native';
import App from './App';
import { name as appName } from './app.json';
import 'react-native-gesture-handler';
AppRegistry.registerComponent(appName, () => App);
这是我的App.js文件:
import * as React from 'react';
import { Button, View } from 'react-native';
import { createDrawerNavigator } from '@react-navigation/drawer';
import { NavigationContainer } from '@react-navigation/native';
function HomeScreen({ navigation }) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Button
onPress={() => navigation.navigate('Notifications')}
title="Go to notifications"
/>
</View>
);
}
function NotificationsScreen({ navigation }) {
return (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Button onPress={() => navigation.goBack()} title="Go back home" />
</View>
);
}
const Drawer = createDrawerNavigator();
export default function App() {
return (
<NavigationContainer>
<Drawer.Navigator initialRouteName="Home">
<Drawer.Screen name="Home" component={HomeScreen} />
<Drawer.Screen name="Notifications" component={NotificationsScreen} />
</Drawer.Navigator>
</NavigationContainer>
);
}
希望这些信息对你有所帮助。如果有其他问题,请随时提出。
英文:
I have successfully installed ReactNative Drawer navigation, but it only works once. From the beginning, the hamburger menu is not functional but I can swipe the drawer out and when I press any navigation item, it takes me to that screen. But after that, it stops working.
I followed the official guide: https://reactnavigation.org/docs/drawer-navigator#installation
HELP Please!!!
This is my package.json
{
"name": "AwesomeProject",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"lint": "eslint .",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"@react-navigation/drawer": "^6.6.2",
"@react-navigation/native": "^6.1.6",
"react": "18.2.0",
"react-native": "0.71.8",
"react-native-gesture-handler": "^2.10.2",
"react-native-reanimated": "^3.2.0",
"react-native-safe-area-context": "^4.5.3",
"react-native-screens": "^3.20.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native-community/eslint-config": "^3.2.0",
"@tsconfig/react-native": "^2.0.2",
"@types/jest": "^29.2.1",
"@types/react": "^18.0.24",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.2.1",
"eslint": "^8.19.0",
"jest": "^29.2.1",
"metro-react-native-babel-preset": "0.73.9",
"prettier": "^2.4.1",
"react-test-renderer": "18.2.0",
"typescript": "4.8.4"
},
"jest": {
"preset": "react-native"
}
}
This is index.js, the entry file:
/**
* @format
*/
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import 'react-native-gesture-handler';
AppRegistry.registerComponent(appName, () => App);
And this is my App.js file:
import * as React from 'react';
import {Button, View} from 'react-native';
import {createDrawerNavigator} from '@react-navigation/drawer';
import {NavigationContainer} from '@react-navigation/native';
function HomeScreen({navigation}) {
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<Button
onPress={() => navigation.navigate('Notifications')}
title="Go to notifications"
/>
</View>
);
}
function NotificationsScreen({navigation}) {
return (
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
<Button onPress={() => navigation.goBack()} title="Go back home" />
</View>
);
}
const Drawer = createDrawerNavigator();
export default function App() {
return (
<NavigationContainer>
<Drawer.Navigator initialRouteName="Home">
<Drawer.Screen name="Home" component={HomeScreen} />
<Drawer.Screen name="Notifications" component={NotificationsScreen} />
</Drawer.Navigator>
</NavigationContainer>
);
}
答案1
得分: 1
@react-navigation/drawer
v6.6.2 现在与 react-native-reanimated
v3.2.0 不兼容。问题已在 GitHub 上提出。https://github.com/react-navigation/react-navigation/issues/11391。
解决方案是将 react-native-reanimated
降级到 v3.1.0。不兼容问题需要由包提供者修复,因此我们需要等待下一个发布。
更改包版本可能会导致缓存问题,请尝试清除缓存后再次尝试。
英文:
@react-navigation/drawer
v6.6.2 is now incompatible with react-native-reanimated
v3.2.0.
Issue is raise in github too. https://github.com/react-navigation/react-navigation/issues/11391.
Solution is downgrade react-native-reanimated
to v3.1.0. Incompatible issue need to be fixed by package provider, so we need to wait until next release.
Changing package version may cause cache issue, please try again with clear cache.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论