【发布时间】:2018-07-07 18:04:46
【问题描述】:
我正在开发一个由react-native@0.55.4 和react-native-navigation@1.1.474 提供支持的应用程序。
最初,只有一个登录屏幕(使用Navigation.startSingleScreenApp)。当用户登录时,我调用Navigation.startTabBasedApp(选项卡组件之一是我的NavScreen)。每当用户更改到另一个选项卡时,应该显示选项卡堆栈的根,所以我尝试了这样的操作:
class NavScreen extends React.PureComponent {
constructor(props) {
super(props)
this.props.navigator.setOnNavigatorEvent(this.toRootOnTabSelect.bind(this))
}
toRootOnTabSelect(event) {
const {id} = event
if (["bottomTabSelected", "bottomTabReselected"].includes(id)) {
this.props.navigator.popToRoot({
animated: true,
animationType: "fade",
})
}
}
render() {
return <Text>Whatever...</Text>
}
}
但由于某种原因,当我更改选项卡时,我的 toRootOnTabSelect 事件处理程序方法没有被调用(通过单击它们 - 而不是通过调用 switchToTab API 方法)。
我在网上找到了多个帖子(即https://stackoverflow.com/a/51159091/6928824、https://github.com/wix/react-native-navigation/issues/648),表明它应该可以工作,所以我不知道我错过了什么。 :/
非常感谢任何帮助! :)
【问题讨论】:
标签: javascript react-native react-native-navigation wix-react-native-navigation