timomeh / react-native-material-bottom-navigation

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

make no tab selected? #102

Open danielzzz opened 6 years ago

danielzzz commented 6 years ago

Question / Problem

Actual behavior

when no activeTab is set there is always the first one selected

Expected behavior

I would like to use this component as a kind of a secondary navigation where the tabs point to some unrelated screens. there is a situation when the current screen is not one of the ones in the bottom nav. in this case none of the tabs should be set as active, but I am not sure how to achieve that.

thx, dan

timomeh commented 6 years ago

Interesting. I never thought of that use case, but it makes sense. Currently it will switch to uncontrolled mode and set the first tab as active, If you don't set an activeTab.

https://github.com/timomeh/react-native-material-bottom-navigation/blob/c970bbfcdf6635de145a9a5da924485f9d17bb26/lib/TabList.js#L55-L57

I think it's a valid point to have no tab active, if no activeTab is set. For uncontrolled mode there should be a defaultTab prop.

If you want to, you can contribute by opening a PR to solve this issue. If not, I can take a look at it when I have some time to spare.