PedroBern / react-native-collapsible-tab-view

A cross-platform Collapsible Tab View component for React Native
MIT License
875 stars 172 forks source link

How to get current tab from outside the TabContext? #71

Closed alexpchin closed 3 years ago

alexpchin commented 3 years ago

If you want to conditionally display content based on the current tab, or you just want to know for some logic which tab is currently focused, you used to be able to work this out from navigationState.

PedroBern commented 3 years ago

How to get the currently focused tab from refMap, previously you could use navigationState.index? How to listen to the change of the tab? (Connected to above)

58 will add onIndexChange prop, here, and the imperative ref handler here, maybe we can add more methods to it, like currectTab: () => focusedTab .value and currentIndex: () => index.value