0
votes

I want to send route params to Profile tab from button click action in Home screen. Below code is tab navigator

  const Tabs = TabNavigator({
  [routes.HOME]: {
    screen: FeedMainScreen,
    navigationOptions: {
      tabBarLabel: tabBarLabels.HOME_TAB_LABEL,
    },
  },
  [routes.SEARCH]: {
    screen: SearchScreen,
    navigationOptions: {
      tabBarLabel: tabBarLabels.SEARCH_TAB_LABEL,
    },
  },
  [routes.PROFILE]: {
    screen: ProfileScreen,
    navigationOptions: {
      tabBarLabel: tabBarLabels.PROFILE_TAB_LABEL,
    },
  },

}

and button click navigation is like this

<Button onPress={() => this.props.navigation.navigate(routes.PROFILE, { id: this.props.user._id }, null)} />

and accsess param from Profile screen like this

constructor (props) {
 super(props)
 console.log('NavPrams', this.props.navigation.state)
}

alwaya undifined

1

1 Answers

0
votes

You can use connect() method to successfully map the props and use them anywhere. Add the below mentioned code in the class where is written -

    const mapStateToProps = state => {
    return {
        user: this.props.user;
    };
};
export default connect(mapStateToProps, {})(className);