每当在 Wix Navigation v2 中更改选项卡时触发 function/event
Trigger function/event whenever changing tab in Wix Navigation v2
每当我在我的 react-native 应用程序中切换到特定选项卡时,我想 运行 一个函数,但我找不到方法。
我知道在 Wix Navigation (RNN) v2 之后,更改当前选项卡的方法是使用 mergeOptions,这很有效。但是,如果我还想在更改选项卡后从该屏幕执行功能怎么办?
这就是我更改标签的方式:
Navigation.mergeOptions(this.props.componentId, {
bottomTabs: {
currentTabIndex: 3
}
}
选项卡已更改,但我找不到在发生此特定事件后添加侦听器或触发事件的方法。
有什么办法可以做到吗?
React-Native: 0.60.5
React-Native-Navigation: 3.1.2
谢谢。
您可以添加一个侦听器,该侦听器将在标签更改时触发。参见 Documentation
试试这个
// Subscribe
const bottomTabEventListener = Navigation.events().registerBottomTabSelectedListener(({ selectedTabIndex, unselectedTabIndex }) => {
});
...
// Unsubscribe
bottomTabEventListener.remove();
每当我在我的 react-native 应用程序中切换到特定选项卡时,我想 运行 一个函数,但我找不到方法。
我知道在 Wix Navigation (RNN) v2 之后,更改当前选项卡的方法是使用 mergeOptions,这很有效。但是,如果我还想在更改选项卡后从该屏幕执行功能怎么办?
这就是我更改标签的方式:
Navigation.mergeOptions(this.props.componentId, {
bottomTabs: {
currentTabIndex: 3
}
}
选项卡已更改,但我找不到在发生此特定事件后添加侦听器或触发事件的方法。
有什么办法可以做到吗?
React-Native: 0.60.5
React-Native-Navigation: 3.1.2
谢谢。
您可以添加一个侦听器,该侦听器将在标签更改时触发。参见 Documentation
试试这个
// Subscribe
const bottomTabEventListener = Navigation.events().registerBottomTabSelectedListener(({ selectedTabIndex, unselectedTabIndex }) => {
});
...
// Unsubscribe
bottomTabEventListener.remove();