Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

React Native: Setting params while switching bottom navigation tabs

$
0
0

I'm using bottom navigation in one of my apps, and have run into a problem.

I want to send some event to the cloud whenever user uses bottom navigation to land on a page, let's say A1.

Here's my code:

const tabBarConfigs = {  lazy: true,  animationEnabled: true,  tabBarComponent: props => <AppBottomTab {...props} />,  tabBarOptions: {    style: {      backgroundColor: Fonts.Colors.transparent,    },    activeTintColor: Fonts.Colors.reddishPink,    inactiveTintColor: Fonts.Colors.fullBlack,    labelStyle: { fontFamily: Fonts.Medium, fontSize: 10, marginTop: -2 },    upperCaseLabel: true,    allowFontScaling: false,    showIcon: true,  },  defaultNavigationOptions: {    tabBarOnPress: ({ navigation, defaultHandler }) => {      defaultHandler();      navigation.setParams({        eventData: {          source: "bottom_nav",        },      });      if (navigation.isFocused()) {        const scrollToTop = navigation.getParam("scrollToTop", null);        if (scrollToTop) {          scrollToTop();        }      }    },  },};

The problem is, when the user lands from any other touchpoint (other than bottom navigation) then also the eventData is already set in navigation. How to avoid that ?

Have been struggling with this for 3 days. Can anyone help here ?


Viewing all articles
Browse latest Browse all 16552

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>