【问题标题】:React Native Navigation initial set up errorReact Native Navigation 初始设置错误
【发布时间】:2019-01-05 11:54:38
【问题描述】:

我第一次尝试为我的 react native 应用程序设置 React Native Navigation,我遇到了这个错误

undefined is not a function (near ... _reactNativeNavigation.Navigation.setRoot...)

我怀疑我设置根导航器的方式存在一些简单的错误。目前只有一个屏幕。

import { Navigation } from 'react-native-navigation';
import RedBall from './components/red-ball';

export default () => {
  Navigation.registerComponent('RedBall', () => RedBall);

  Navigation.setRoot({
    root: {
      bottomTabs: {
        children: [{
          component: {
            name: 'RedBall',
            passProps: {
              text: 'This is the red ball screen'
            },
            options: {
              bottomTab: {
                text: 'Red Ball',
                testID: 'RED_BALL'
              }
            }
          }
        }]
      }
    }
  });
};

有人发现代码中有任何明显的缺陷吗? 谢谢

【问题讨论】:

    标签: react-native react-native-navigation


    【解决方案1】:

    应该在应用启动后使用appLaunchedListener调用设置root

    另一件事是,BottomTab 在 Android 上需要 icon

    【讨论】:

      猜你喜欢
      • 2019-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多