反应本机导航初始设置错误

时间:2018-07-28 17:05:34

标签: react-native react-native-navigation

我正在尝试为我的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'
              }
            }
          }
        }]
      }
    }
  });
};

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

1 个答案:

答案 0 :(得分:1)

在使用appLaunchedListener启动应用后,应调用设置根目录

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