msqar
msqar

Reputation: 3020

Bridge not yet loaded! thrown when using latest Wix React-Native-Navigation

I was using RNN V1 and decided to update to the latest since I needed more customization, it updated to the V3-alpha. Don't know if this was a mistake from my part or not, if I prolly should go to latest V2 for more stability. Thing is, whenever I start my project on a different mac, it throws the following error:

Exception 'Bridge not yet loaded! Send commands after Navigation.events().onAppLaunched() has been called.' was thrown while invoking setDefaultOptions on target RNNBridgeModule with params (
        {
        statusBar =         {
            style = light;
            visible = 1;
        };
        topBar =         {
            visible = 0;
        };
    },
    30,
    31
)
callstack: (

The only place where i set the setDefaultOptions was when starting the tab based navigation.

This is the code for that.

import { Navigation } from 'react-native-navigation';
import { iconsMap } from '../../_global/AppIcons';
import i18n from '../../_global/i18n';
import { navigatorStyle } from '../../styles/navigatorStyles';

Navigation.setDefaultOptions({
    statusBar: {
        visible: true,
        style: 'light'
    },
    topBar: {
        visible: false
    }
});

const startTabs = () => {
    Navigation.setRoot({
        root: {
            bottomTabs: {
                animate: true,
                visible: false,
                drawBehind: true,
                elevation: 8,
                children: [
                    {
                        stack: {
                            children: [
                                {
                                    component: {
                                        id: 'MainTab',
                                        name: 'app.MainTab'
                                    }
                                }
                            ],
                            options: {
                                bottomTab: {
                                    text: i18n.t('main'),
                                    icon: iconsMap['home'],
                                    ...navigatorStyle
                                }
                            }
                        }
                    },
                    {
                        stack: {
                            children: [
                                {
                                    component: {
                                        id: 'MyProfileTab',
                                        name: 'app.MyProfileTab'
                                    }
                                }
                            ],
                            options: {
                                bottomTab: {
                                    text: i18n.t('myProfile'),
                                    icon: iconsMap['md-person'],
                                    ...navigatorStyle
                                }
                            }
                        }
                    },
                    {
                        stack: {
                            children: [
                                {
                                    component: {
                                        id: 'MessageScreen',
                                        name: 'app.MessageScreen'
                                    }
                                }
                            ],
                            options: {
                                bottomTab: {
                                    text: i18n.t('messages'),
                                    icon: iconsMap['comment-dots'],
                                    badge: '2',
                                    badgeColor: 'red',
                                    ...navigatorStyle
                                }
                            }
                        }
                    }
                ]
            }
        }
    });
}

export default startTabs;

On my main macbook used to work, why is not working on a different computer? what could I be possibly be doing wrong or missing here? I got the latest code on both. Even tried commenting out the setDefaultOptions but the error still shows up.

Any help will be appreciated.

Upvotes: 1

Views: 1582

Answers (1)

Raphael Karanja
Raphael Karanja

Reputation: 3074

The most likely option is how you are passing the default Options. Make sure you pass them inside registerAppLaunchedListener before Navigation.setRoot({}) option. Navigation.events().registerAppLaunchedListener(() => { // here }.

So your code will look something like this.

Navigation.events().registerAppLaunchedListener(() => {

  Navigation.setDefaultOptions({
    //options here
  })

  Navigation.setRoot({
     root: {
          bottomTabs: {
            //bottom tabs option
          }
     }
  });

});

Upvotes: 6

Related Questions