popTo causes an infinite loop when route is not found
See original GitHub issueVersion
Tell us which versions you are using:
- react-native-router-flux v4.0.0 beta 27 (v3 is not supported)
- react-native v0.5.5
Expected behaviour
- popTo returns
null
or throws an Error of some kind
Actual behaviour
When calling Actions.popTo
on a route that is not in the navigation stack, it infinite loops (inside of the Reducer
)
Additionally, I expected it to “just work” given a parent route. More context:
- I have some tabs and some modals of $N depth. One of the modals are the current scene. I want to dismiss the modal. Going back just once might not be enough. The route I want to go back to is whichever was last selected on a tab. To do that, I wrongly assumed I could pass
Actions.popTo
the tabs route and it would “just work”, instead it infinite loops. - My solution is to manually track what the last child route of the tab bar that was active, and
popTo
that child route
Steps to reproduce
For non-obvious bugs, please fork this component, modify Example project to reproduce your issue and include link here.
- Open your app
- Call `Actions.popTo(“AnyRouteThatDoesntExist”)
- Infinite loop
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
Express Routes causing infinite loop - node.js - Stack Overflow
exports = router;. Whenever i try to access localhost:3000/photo/123 it goes into infinite loop. However /sample is working fine.
Read more >Something with $route as I use it causing an infinite loop
I seem to have found the problem on accident by rewriting the routing controller. Since I'm working with a site that has a...
Read more >Avoiding Infinite Loops with Internal Relay Domains in ...
How to avoid creating an infinite email routing loop in Exchange Server 2007/2010 when configuring Internal Relay domains.
Read more >CWE-835: Loop with Unreachable Exit Condition ('Infinite Loop')
The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop. + Extended Description.
Read more >Is while true an infinite loop? - Quora
“True” will always return true for reasons I hope are obvious, ... No infinite loops here! ... Find the loop, fix the loop...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Jarred-Sumner I am able to reproduce the error - but it seems to be related to
react-navigation
. But I believe something can be done over it to avoid that. I will spare some time this week to investigate this issue. Thank you.Hi,
I’ve had issues with Android (using a Drawer with a nested scene) and iOS using a tabBar with nested scenes together with normal scenes (router here:https://github.com/crownstone/CrownstoneApp/blob/master/js/router/RouterIOS.js#L35)
I solved this by going into nested sets to find the key: https://github.com/crownstone/CrownstoneApp/blob/master/js/router/store/reducers/navigation.ts
Basically, I reconstruct the state to have only the scene I’m at and the target scene, then use a normal back action to have the animation.
I think it’s a little shortsighted to only compare the routename and not account for nesting… If you have a router like:
Then do Actions.1(), to go from 2 -> 1, then Actions.popTo(2) and it fails.
Cheers