react-nativetabs

How can I detect blur event in React Native tab component?


I'm using rmc-tabs for tab component in React Native. I'm using video component and want to pause the video when I move to other tab, but I don't know how to do this. How can I get the blur event in rmc-tabs or are there any other ways to handle blur event in React Native video or view?


Solution

  • if you are using createTabNavigator or createBottomTabNavigator you can use NavigationEvents within the screens inside TabNavigator which allow you to listen to

    onWillFocus : before focusing a tab;
    onDidFocus : after focusing a tab;
    onWillBlur : before losing focus on a tab;
    onDidBlur : after losing focus on a tab;