react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

registerBottomTabSelectedListener does not fire callback on tab change

Open rishabhpoddar opened this issue 8 years ago • 4 comments

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

rishabhpoddar avatar Oct 08 '18 16:10 rishabhpoddar

I think I may have solved the issue. But i am not sure: Added "self.delegate = self;" in function initWithLayoutInfo in RNNTabBarController.m

rishabhpoddar avatar Oct 08 '18 17:10 rishabhpoddar

@rishabhpoddar this is correct.

jcsena avatar Oct 12 '18 02:10 jcsena

@jcsena cheers!

rishabhpoddar avatar Oct 12 '18 12:10 rishabhpoddar

Fixed fee53a1a914bceb2980a5f682d57ed267257c480 Thanks

yogevbd avatar Oct 17 '18 08:10 yogevbd