Search code examples
react-nativereduxrouterfluxtabbar

Change tabbar button behaviour on second press


I'm using router flux in a react native project (0.43.3)

How is it possible in the tabbar to just switch the tab when the icon is first pressed and to reset the stack on this tab on second press?

Example:

1. In: tab1
2. Press tab2-icon => switch to tab2 (scene tab2 must be showed)
3. Press tab1-icon => switch to tab1 (scene tab1 must be showed, just as it had been)
4. Press tab1-icon => switch to tab1 (scene tab 1 must be reload with a different prop)

I tried adding to scene the actions into onPress <Scene onPress={() => { /* CODE */ }} ...> but lost (overwriting or replacing) the own actions of router flux tabbar (like display the scene component, mark as active, change the color to the tabbar item). Maybe if I can add the actions when tabbar is pressed in the onPress y default, and after that my code I will do that


original question in repo by @mantir: https://github.com/aksonov/react-native-router-flux/issues/1905


Solution

  • Since 3.39.1, you should be able to handle it with onActivePress.

    As explain in this pullRequest, it is triggered when the tab is already selected !