-1

For calling a stackNavigator we use props.navigation.navigate('home').

But how to call for alert when i clicked on a bottom tab navigation icon.

Riyaz Mirza
  • 149
  • 1
  • 2
  • 8

2 Answers2

0

You can use tabBarOnPress in navigationOptions as below

CreatePostt: {
    screen: createStackNavigator(
        {
            CreatePost: {
                screen: CreatePost,
                navigationOptions: {
                    // header: null
                }
            },

            PostExpanded: {
                screen: PostExpanded,
                navigationOptions: {
                    title: "Upload Post",
                    headerStyle: {
                        elevation: 1
                    },
                }
            },


        },
        {
            defaultNavigationOptions: {
                headerTitleStyle: {
                    fontWeight: "bold"
                }
            }
        }
    ),
        navigationOptions: {
        tabBarOptions: {
            showIcon: true,
                showLabel: false
        },
        tabBarVisible: false,
            labelStyle: { margin: 0, padding: 0 },
        title: "",
            tabBarIcon: ({ focused }) => <BtnPost style={{ marginTop: 15 }} />,
                tabBarOnPress: ({ navigation, defaultHandler }) => {

                }
    }
},
Rajan
  • 1,512
  • 2
  • 14
  • 18
0

thanks.. it is working.....

const AlertStack = createStackNavigator(
  {
    Alert: AlertScreen

  },
);

AlertStack.navigationOptions = {
  tabBarOnPress: () => {
 alert('Hello');
  },
  };
d219
  • 2,707
  • 5
  • 31
  • 36
Riyaz Mirza
  • 149
  • 1
  • 2
  • 8