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

Question: Is there any suitable way to unsubscribe event on tab change #2803

Closed
sadi304 opened this issue Oct 22, 2017 · 6 comments
Closed

Comments

@sadi304
Copy link

sadi304 commented Oct 22, 2017

Hello,
I am aware of the issue that component life cycle hooks don't get called if a tab is rendered already. I have an event in a tab (Shake Event), the problem is even when i switch the tab the event is already subscribed as componentwillunmount is never called from that screen (that leads to no remove listener of the event to be called). So in other screen the event is occuring also. I am asking for help if there's any suitable way to handle this scenario. I am not using redux. TIA

@spencercarli
Copy link
Member

Have you tried using the tabBarOnPress to take care of the issue?

@sadi304
Copy link
Author

sadi304 commented Oct 28, 2017

@spencercarli , there is a problem in that case. If backbutton is pressed or again home tab then the event is not instantiated again . No idea why this is happening .

@spencercarli
Copy link
Member

Can you put together a demo of the behavior you're seeing? I'm not sure I'm following

@sadi304
Copy link
Author

sadi304 commented Oct 29, 2017

okay i will post the code . later .

@brentvatne
Copy link
Member

you can use this.props.navigation.addListener for this! https://reactnavigation.org/docs/navigation-prop.html#addlistener-subscribe-to-updates-to-navigation-lifecycle

@sadi304
Copy link
Author

sadi304 commented Feb 8, 2018

moved to router flux at this moment. handling via onEnter and onExit props .

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

4 participants