timomeh / react-native-material-bottom-navigation

💅🔧👌 a beautiful, customizable and easy-to-use material design bottom navigation for react-native
MIT License
710 stars 127 forks source link

onPress on tab not working #65

Closed akhilesh08061 closed 6 years ago

akhilesh08061 commented 6 years ago

onTabChange is perfectly working in react native material bottom navigation.but as given in a documentation that you can even use onPress on individual tabs.but it is not working for my case. example:- <BottomNavigation> <Tab onPress={(newTabIndex)=>console.log(newTabIndex)} label="movie" icon={<Image src={require("image address")}/> } /> </BottomNavigation>

timomeh commented 6 years ago

If you use onPress, you have to handle activeTab by yourself. See this working example: https://snack.expo.io/rJzZgos7f

The docs are very explicit about this behavior:

Function to be called when the Tab was pressed. When you use this, the pressed tab won't be active automatically. You need to set it to active by updating BottomNavigation.activeTab.

I would advise against using onPress and recommend using onTabChange. The onPress prop exists mainly to support react-navigation.

akhilesh08061 commented 6 years ago

Thank you very much.i will try your solution.