-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Idempotent navigate with key for StackRouter #3393
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test case check failed
577c496
to
11f35ef
Compare
Codecov Report
@@ Coverage Diff @@
## master #3393 +/- ##
==========================================
- Coverage 72.95% 72.75% -0.21%
==========================================
Files 52 53 +1
Lines 1638 1659 +21
Branches 428 435 +7
==========================================
+ Hits 1195 1207 +12
- Misses 349 357 +8
- Partials 94 95 +1
Continue to review full report at Codecov.
|
08b07b6
to
de0ee44
Compare
de0ee44
to
495be80
Compare
@ericvicenti please include same solution to NavigationActions. Other way redux user can get your solution. |
look at the diff @dann1609, you can use this with redux, just include the key in the action... |
@brentvatne I did and didn't work. |
@dann1609, can you please file a detailed issue with the exact example code that demonstrates the problem? Otherwise we can’t help you. |
@ericvicenti I do my navigation using the next code:
App navigate without problem, but next page (in stack navigator) set a random key, not the key provided. So, the next time I call the same dispatch. Navigation will create the same page, but a new one, since key provided is not the same key of previous pages. |
Using key StackNavigator triggers transition twice when double tapping fast . |
I tried supplying the key of the current screen to navigate, it works and prevents multiple stacking with multiple touching, but it only works once. If I want to navigate one more level deeper then it won't do it. I think the reason is that once I supply the current key, the router propagates/memorizes it so that I cant navigate twice since the key remains the same at the second navigate. To be more specific the navigation structure looks like this:
in Screen1: The So the question is, how do I correctly use this new feature? Thanks. |
@ericvicenti Hope you got some time to take a look 😄 |
I can only help if you post a MVCE of your problem: https://stackoverflow.com/help/mcve Otherwise it’s not clear what is going on |
I've been looking for something like this for ages. @marsonmao If you are using a StackNavigator, the first route by default will have a random key unless you specify it in the StackNavigator configs |
Does the documentation include any examples of what makes for a good key? |
- Obsolete after react-navigation/react-navigation#3393
The navigation action will now always behave idempotently when called with a key. When pushing, it will push a route with that key. If the route already exists, it will navigate to that route and set the params.
This is a commonly requested feature, and will address the needs of #2334 #135 #1313, #2400, #2578