桥梁尚未加载!使用最新的 Wix React-Native-Navigation 时抛出
Bridge not yet loaded! thrown when using latest Wix React-Native-Navigation
我正在使用 RNN V1 并决定更新到最新版本,因为我需要更多定制,它更新到 V3-alpha。不知道这是否是我的错误,如果我很可能应该去最新的 V2 以获得更高的稳定性。
问题是,每当我在另一个 mac 上开始我的项目时,它都会抛出以下错误:
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: (
我设置 setDefaultOptions
的唯一地方是在启动基于选项卡的导航时。
这是代码。
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;
在我的 mac 主书中曾经可以工作,为什么在不同的计算机上不能工作?我可能在这里做错或遗漏了什么?我得到了两者的最新代码。
甚至尝试注释掉 setDefaultOptions 但错误仍然出现。
任何帮助将不胜感激。
最有可能的选项是您传递默认选项的方式。确保在 Navigation.setRoot({})
选项之前将它们传递到 registerAppLaunchedListener
中。
Navigation.events().registerAppLaunchedListener(() => { // here }
.
因此您的代码将如下所示。
Navigation.events().registerAppLaunchedListener(() => {
Navigation.setDefaultOptions({
//options here
})
Navigation.setRoot({
root: {
bottomTabs: {
//bottom tabs option
}
}
});
});
我正在使用 RNN V1 并决定更新到最新版本,因为我需要更多定制,它更新到 V3-alpha。不知道这是否是我的错误,如果我很可能应该去最新的 V2 以获得更高的稳定性。 问题是,每当我在另一个 mac 上开始我的项目时,它都会抛出以下错误:
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: (
我设置 setDefaultOptions
的唯一地方是在启动基于选项卡的导航时。
这是代码。
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;
在我的 mac 主书中曾经可以工作,为什么在不同的计算机上不能工作?我可能在这里做错或遗漏了什么?我得到了两者的最新代码。 甚至尝试注释掉 setDefaultOptions 但错误仍然出现。
任何帮助将不胜感激。
最有可能的选项是您传递默认选项的方式。确保在 Navigation.setRoot({})
选项之前将它们传递到 registerAppLaunchedListener
中。
Navigation.events().registerAppLaunchedListener(() => { // here }
.
因此您的代码将如下所示。
Navigation.events().registerAppLaunchedListener(() => {
Navigation.setDefaultOptions({
//options here
})
Navigation.setRoot({
root: {
bottomTabs: {
//bottom tabs option
}
}
});
});