Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom function on tab press #2271

Closed
perlovka-studio opened this issue Aug 20, 2017 · 3 comments
Closed

Custom function on tab press #2271

perlovka-studio opened this issue Aug 20, 2017 · 3 comments

Comments

@perlovka-studio
Copy link

perlovka-studio commented Aug 20, 2017

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?

@aksonov
Copy link
Owner

aksonov commented Aug 21, 2017

Unfortunately v4 tabbar is breaking change (because it is based on react-navigation TabNavigator now). It looks like duplicate of react-navigation/react-navigation#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.

@aksonov
Copy link
Owner

aksonov commented Aug 21, 2017

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

@aksonov
Copy link
Owner

aksonov commented Aug 23, 2017

Closing this ticket because onEnter should be enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants