-
Notifications
You must be signed in to change notification settings - Fork 16
Automatically prevent double navigation actions somehow #16
Comments
I'm of two opinions. Firstly, I don't think react-navigation should be responsible for preventing this on its own. It's an interesting extra feature, but I don't think react-navigation handling this should be the gold standard. Secondly however, if you do want to handle this automatically as an extra feature I have already come up with a fairly unobtrusive way of making navigate actions idempotent automatically. |
Native handles this automatically, and it's a common enough issue that react navigation should handle automatically IMO. I think it's unreasonable to manually handle it for every button in the app even if it was easy. From my reply in the discussion on slack earlier: I think we need several heuristics to block duplicate navigation actions:
Otherwise, it might block intentional navigations, e.g. user clicked another button or press back before the transition actually finished, or there is a |
When are you planning to release a new version which will have the capability to accept key in navigation function? |
@Vishal1419 - |
key works for most cases, but if you navigate from the side drawer and then open the sidedrawer again and navigate to the same key it breaks :(. These bugs need to be fixed, but yeah let's keep the key solution! My workaround for this situation is the following:
|
@evanjmg - can you post a demo of this on https://snack.expo.io? happy to investigate that |
I've been using the
|
will need you to post a repro case to https://snack.expo.io @radiodario. this works as expected for me: https://snack.expo.io/SyeO1SwOG |
I have an example here when I go to B, I can't go back to A? Shouldn't it go back to it without using goBack or without the key? Without using key, I can go to a new view - but again that adds more to the stack. https://snack.expo.io/@evanjmg/idempotent-navigate . Unfortunately I cannot reproduce my sidebar bug - it's on a very large enterprise project, but I think nested navigators need more work. Also, open the sidebar and click the one of buttons really fast. They will eventually stop working on slow taps, it's not an issue for without key. |
@evanjmg - I re-organized that example to be a bit more clear: https://snack.expo.io/SJxu8wv_f you can't navigate to A with the key
what do you mean? it's not possible to act on feedback like this, we need more specific information ;)
can't repro this, can you post a video? what does stop working mean? |
Some improvements:
|
see the rfc i mentioned |
oh. not work on my device huawei y221 ! |
I completely agree with @satya164 , it's really a big issue for a lot of users and especially in production apps (users have different mobile phones, old/laggy ...), and react-navigation should be able to handle it (checking the route name and params before pushing a new route). @brentvatne I have tried idempotent pushes but in dev mode it display the red screen (should not push route with duplicated key) when you push a route with the same key, and sometimes it mounts the same screen and unmout it quickly. We're using now debouncing on every button in our app to avoid duplicating screens (which is just a hack). I hope that we can find a solution for this issue, and would love to help if necessary ! |
@rbadr Are you able to use unique keys? |
@jeevantakhar I'm generating my own custom unique key |
I'm getting the same error as @radiodario. @brentvatne
Error: |
This issue occurs if you rapidly press on something to navigate it will try to push a duplicate scene. To solve this keep track of the scene once you call navigate and make sure its not === to the same route onPress. |
+1 |
This issue is fixed in recent versions of |
I am using |
I think about 1.5. But you should switch to v2 |
Thanks! It works! |
Still not fixed in V2 it can navigate twice to same scene even if using a unique key to navigate(). |
@MacKentoch - post an issue with a repro |
You can do this manually with idempotent pushes now: react-navigation/react-navigation.github.io#42
But it would be nice if we can somehow handle this automatically (without resorting to some kind of debouncing of the actions): react-navigation/react-navigation#1348
The text was updated successfully, but these errors were encountered: