React Native Drawer Navigation v6.6.2 在 React Native Reanimated v3.2.0 中存在问题。

huangapple go评论68阅读模式
英文:

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

{
  &quot;name&quot;: &quot;AwesomeProject&quot;,
  &quot;version&quot;: &quot;0.0.1&quot;,
  &quot;private&quot;: true,
  &quot;scripts&quot;: {
    &quot;android&quot;: &quot;react-native run-android&quot;,
    &quot;ios&quot;: &quot;react-native run-ios&quot;,
    &quot;lint&quot;: &quot;eslint .&quot;,
    &quot;start&quot;: &quot;react-native start&quot;,
    &quot;test&quot;: &quot;jest&quot;
  },
  &quot;dependencies&quot;: {
    &quot;@react-navigation/drawer&quot;: &quot;^6.6.2&quot;,
    &quot;@react-navigation/native&quot;: &quot;^6.1.6&quot;,
    &quot;react&quot;: &quot;18.2.0&quot;,
    &quot;react-native&quot;: &quot;0.71.8&quot;,
    &quot;react-native-gesture-handler&quot;: &quot;^2.10.2&quot;,
    &quot;react-native-reanimated&quot;: &quot;^3.2.0&quot;,
    &quot;react-native-safe-area-context&quot;: &quot;^4.5.3&quot;,
    &quot;react-native-screens&quot;: &quot;^3.20.0&quot;
  },
  &quot;devDependencies&quot;: {
    &quot;@babel/core&quot;: &quot;^7.20.0&quot;,
    &quot;@babel/preset-env&quot;: &quot;^7.20.0&quot;,
    &quot;@babel/runtime&quot;: &quot;^7.20.0&quot;,
    &quot;@react-native-community/eslint-config&quot;: &quot;^3.2.0&quot;,
    &quot;@tsconfig/react-native&quot;: &quot;^2.0.2&quot;,
    &quot;@types/jest&quot;: &quot;^29.2.1&quot;,
    &quot;@types/react&quot;: &quot;^18.0.24&quot;,
    &quot;@types/react-test-renderer&quot;: &quot;^18.0.0&quot;,
    &quot;babel-jest&quot;: &quot;^29.2.1&quot;,
    &quot;eslint&quot;: &quot;^8.19.0&quot;,
    &quot;jest&quot;: &quot;^29.2.1&quot;,
    &quot;metro-react-native-babel-preset&quot;: &quot;0.73.9&quot;,
    &quot;prettier&quot;: &quot;^2.4.1&quot;,
    &quot;react-test-renderer&quot;: &quot;18.2.0&quot;,
    &quot;typescript&quot;: &quot;4.8.4&quot;
  },
  &quot;jest&quot;: {
    &quot;preset&quot;: &quot;react-native&quot;
  }
}

This is index.js, the entry file:

/**
 * @format
 */
import {AppRegistry} from &#39;react-native&#39;;
import App from &#39;./App&#39;;
import {name as appName} from &#39;./app.json&#39;;
import &#39;react-native-gesture-handler&#39;;

AppRegistry.registerComponent(appName, () =&gt; App);

And this is my App.js file:

import * as React from &#39;react&#39;;
import {Button, View} from &#39;react-native&#39;;
import {createDrawerNavigator} from &#39;@react-navigation/drawer&#39;;
import {NavigationContainer} from &#39;@react-navigation/native&#39;;

function HomeScreen({navigation}) {
  return (
    &lt;View style={{flex: 1, alignItems: &#39;center&#39;, justifyContent: &#39;center&#39;}}&gt;
      &lt;Button
        onPress={() =&gt; navigation.navigate(&#39;Notifications&#39;)}
        title=&quot;Go to notifications&quot;
      /&gt;
    &lt;/View&gt;
  );
}

function NotificationsScreen({navigation}) {
  return (
    &lt;View style={{flex: 1, alignItems: &#39;center&#39;, justifyContent: &#39;center&#39;}}&gt;
      &lt;Button onPress={() =&gt; navigation.goBack()} title=&quot;Go back home&quot; /&gt;
    &lt;/View&gt;
  );
}

const Drawer = createDrawerNavigator();

export default function App() {
  return (
    &lt;NavigationContainer&gt;
      &lt;Drawer.Navigator initialRouteName=&quot;Home&quot;&gt;
        &lt;Drawer.Screen name=&quot;Home&quot; component={HomeScreen} /&gt;
        &lt;Drawer.Screen name=&quot;Notifications&quot; component={NotificationsScreen} /&gt;
      &lt;/Drawer.Navigator&gt;
    &lt;/NavigationContainer&gt;
  );
}

答案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.

huangapple
  • 本文由 发表于 2023年6月1日 04:12:54
  • 转载请务必保留本文链接:https://go.coder-hub.com/76376947.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定