msq*_*qar 1 react-native 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: (
Run Code Online (Sandbox Code Playgroud)
我设置的唯一地方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;
Run Code Online (Sandbox Code Playgroud)
在我以前的主要 macbook 上工作,为什么不能在不同的计算机上工作?我在这里可能做错了什么或遗漏了什么?我得到了两者的最新代码。甚至尝试注释掉 setDefaultOptions 但错误仍然出现。
任何帮助将不胜感激。
最有可能的选项是您如何传递默认选项。确保registerAppLaunchedListener在Navigation.setRoot({})选择之前将它们传递给内部。
Navigation.events().registerAppLaunchedListener(() => { // here }.
所以你的代码看起来像这样。
Navigation.events().registerAppLaunchedListener(() => {
Navigation.setDefaultOptions({
//options here
})
Navigation.setRoot({
root: {
bottomTabs: {
//bottom tabs option
}
}
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
804 次 |
| 最近记录: |