-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[V2] Events: No way to listen to screen pop when performed via gesture or hitting back button #3941
Comments
+1 |
Very important for me too |
I have the same problem. @guyca Did you work on this? |
Hey guys, we'll add the following event to support this use case: Navigation.events().registerScreenPoppedListener({ componentId } = {
}); The event will be emitted each time a screen is popped, regardless of whether it was popped by |
@guyca hey guy, is telling me that registerScreenPoppedListener is not a function. In what version of RNN was this added? I'm using 3.7.0. Thanks! EDIT: I installed the latest possible version of RNN, which is Within my component constructor I have:
Then i do screenPoppedListener.remove() during WillUnmount. But is never showing the console log. Any idea? |
Hey @msqar On which platform are you not getting the event? |
@guyca on iOS 13, didn't test on Android though. I ended up using a different library that would handle event listeners to solve it :( since i couldn't make this one work, don't know why, even by updating to latest. |
Called each time a screen is popped, either due to `Navigation.pop` or pop gesture. closes wix#3941 Navigation.events().registerScreenPoppedListener(({ componentId }) => { });
@guyca can confirm the Checked on iOS 13.4.1 with RNN version 6.4.0 |
I'm using |
@eightyfive screenPopped event works as expected on latest RNN, please upgrade and open a new issue with a reproduction if you think there's still an issue 👍 |
Issue Description
When registering a command listener, the only events subscribed to are the ones explicitly called on Navigation class from my code. The implicit commands (gesture swipe back, system back button) don't get picked up by this listener so there is effectively no way to detect that they happened.
The componentDidAppear/didDisappear listeners could be used if there was context with the event (command that resulted in the screen being mounted/unmounted).
Ultimately what I'm trying to do is trigger some side effect on screen pop. I can override the back button with my own button and manually call the pop command, but that doesn't solve the gesture back case and it seems like this is a departure from the way that v1 handled this, which was to provide a handler for all events and then let the implementer filter out as needed.
Steps to Reproduce / Code Snippets / Screenshots
Environment
The text was updated successfully, but these errors were encountered: