react-native-navigation
react-native-navigation copied to clipboard
registerBottomTabSelectedListener does not fire callback on tab change
Issue Description
Navigation.events().registerBottomTabSelectedListener(someFunc) does not fire someFunc when tabs are changed. My code is below (I am using Typescript. But that should have no effect on this discussion):
constructor(props: any) {
super(props);
this.eventSubscription = Navigation.events().registerBottomTabSelectedListener(this.tabChanged);
}
tabChanged = (info: { selectedTabIndex: number, unselectedTabIndex: number }) => {
this.props.onBottomTabChanged(info.selectedTabIndex);
}
componentWillUnmount() {
this.eventSubscription.remove();
super.componentWillUnmount();
}
Environment
- React Native Navigation version: 2.0.2577
- React Native version: 0.53.3
- Platform(s) (iOS, Android, or both?): iOS
- Device info (Simulator/Device? OS version? Debug/Release?): Device, 12.0.0, Debug
I think I may have solved the issue. But i am not sure: Added "self.delegate = self;" in function initWithLayoutInfo in RNNTabBarController.m
@rishabhpoddar this is correct.
@jcsena cheers!
Fixed fee53a1a914bceb2980a5f682d57ed267257c480 Thanks