【问题标题】:react-native missing navigation on react natvigation反应导航上的反应本机缺少导航
【发布时间】:2022-01-01 23:00:03
【问题描述】:

我使用 react native 0.66.0 和 react navigation 4.4.4 使用 yarn android 运行应用程序时出现错误:

undefined 不是对象 navigation.state.params.name

将文件添加到mainActivity.java 类似文档 这是我的App.js 文件我的应用程序中只有一个文件

【问题讨论】:

  • 当我将 react native 更改为 0.63.0 时运行
  • 我错过的操作不起作用!!!!!!!!!

标签: javascript android react-native react-navigation


【解决方案1】:

我认为您可以通过在 MainActivity.java 中添加此代码来实现

代码

package com.reactnavigation.example;

import com.facebook.react.ReactActivity;
+ import com.facebook.react.ReactActivityDelegate;
+ import com.facebook.react.ReactRootView;
+ import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;

public class MainActivity extends ReactActivity {

  @Override
  protected String getMainComponentName() {
    return "Example";
  }

+  @Override
+  protected ReactActivityDelegate createReactActivityDelegate() {
+    return new ReactActivityDelegate(this, getMainComponentName()) {
+      @Override
+      protected ReactRootView createRootView() {
+        return new RNGestureHandlerEnabledRootView(MainActivity.this);
+      }
+    };
+  }
}

【讨论】:

  • 我这样做了,但不起作用
【解决方案2】:

我的问题是

我使用navigation.state.params,但不将参数发送到导航

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-29
    • 2021-10-30
    • 2021-12-11
    • 2021-09-13
    • 1970-01-01
    • 2021-06-13
    • 1970-01-01
    相关资源
    最近更新 更多