-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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] How to add Android Back Handler for a perticular screen? #15248
Comments
How do you handle your navigation betwen scene? Are you using react-navigation or router-flux ? |
@Dani93380 I am using react-native-router-flux v4 which is a wrapper on react-navigation only |
You should have 3 class for your 3 components . If you add the listener inside the AddDoc class only and remove it on componentWillUnmount it should work. |
Actually, I have done the same but what happens is, this event listener if not removed will be there on all the screens. |
If you are using redux or something similar , store your current scene in the store and only call your back function if currentScene=="AddDoc" |
No I am not using redux or anything. But I think react native should provide such options |
Never mind figured out that react-native-router-flux has |
BTW @Dani93380 I know about Redux but don't want to use in my app :D |
I have three screens MyVault, Add Doc and Add Repo. From Myvault there is one button add new doc by clicking on that Add Doc will open. Now in Add doc if user presses Bank button then I want a confirmation pop up. I have one button inside add doc screen which opens Add repo screen where user can select one repo and when they click add that screen will be poped and add doc screen will be refreshed with the repo data. If I add a listener in ComponentDidMount and then remove it in ComponentWillUnmount then the issue is that even when I press back on Add repo then also the popup comes. I don't want popup on any other screens, I just want it on Add doc.
The text was updated successfully, but these errors were encountered: