Jon_B
Jon_B

Reputation: 1079

React Native Navigation initial set up error

I'm trying to set up React Native Navigation for my react native app for the first time and I'm running into this error

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

I suspect there's some simple error in how I set up my root navigator. There's currently only one screen.

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'
              }
            }
          }
        }]
      }
    }
  });
};

Does anyone recognize any obvious flaws in the code? Thank you

Upvotes: 0

Views: 219

Answers (1)

guy.gc
guy.gc

Reputation: 3501

Set root should be called after the app has launched using appLaunchedListener

Another thing is that BottomTab requires an icon on Android

Upvotes: 1

Related Questions