我正在使用来自Wix的react-native-navigation v2,尝试将屏幕推送到现有堆栈。这是我的推送代码:
Navigation.push(this.props.componentId, {
component: {
name: 'chapel.search'
}
})
我的选择对象
static options (passProps) {
console.log('Firing static method')
return {
component: {
name: 'chapel.search',
topBar: {
visible: true,
leftButtons: [
{
id: 'back',
testID: 'back',
icon: require('../../Images/back.png')
}
],
title: {
component: {
name: 'chapel.navtitle',
alignment: 'center',
passProps: { text: 'Search' }
}
},
rightButtons: []
}
}
}
}
我从未看到日志语句和topbar选项不会更改。他们应该吗?
当我在目标屏幕的Navigation.mergeOptions
中使用constructor
和上面的选项对象时,会出现选项,所以这就是我现在使用的。
使用android,尚未测试iOS。我会更新。
我在我的组件中创建了这样的静态选项:
static get options() {
return {
...
}
}
当我从另一个屏幕推出并想要覆盖一些默认值时,我会像下面这样做:
Navigation.push(this.props.componentId, {
component: {
name: 'chapel.search',
passProps: {
myProp: myprop1
},
options: {
topBar: {
title: {
text: newTitleOverridingStaticOne
}
}
}
}
});
我不知道static options (passProps){...}
是否有效,但您可以尝试我上面显示以检查它是否已解决