React-native-router-flux: Custom function on tab press

Created on 20 Aug 2017  路  3Comments  路  Source: aksonov/react-native-router-flux

Version

  • react-native-router-flux v4.0.0-beta.18
  • react-native v0.46.1

I'm trying to create something like Instagram. When tab is active and you press on it's icon, it refreshes.
<Scene key = "tabBar" tabs>
<Scene key = "news" onPress = { () => {
if (this.state.active[0]) { //if this tab is active
refreshNews(); //fetching to get new data
} else {
this.setState({active: [true, false, false, false]});
Actions.news(); // just open this tab
}
}}>
...
</Scene>
....
</Scene>

Expected behaviour

In previous version (3.37.0 for example) everithing worked fine.

Actual behaviour

In current version onPress function is not performed.

So do I need to downgrade the version or are there any other solutions?

help wanted

All 3 comments

Unfortunately v4 tabbar is breaking change (because it is based on react-navigation TabNavigator now). It looks like duplicate of https://github.com/react-community/react-navigation/issues/314, please check maxmcd's workaround from there. I think we could integrate it somehow into RNRF, need to think about it. PR is welcome.

Btw, you may use onEnter handler for each tab scene if you need to do some actions when tab is selected.

Closing this ticket because onEnter should be enough.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maphongba008 picture maphongba008  路  3Comments

tonypeng picture tonypeng  路  3Comments

xnog picture xnog  路  3Comments

llgoer picture llgoer  路  3Comments

VictorK1902 picture VictorK1902  路  3Comments