question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

popTo causes an infinite loop when route is not found

See original GitHub issue

Version

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.

  1. Open your app
  2. Call `Actions.popTo(“AnyRouteThatDoesntExist”)
  3. Infinite loop

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
daviscabralcommented, May 14, 2018

@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.

0reactions
AlexDM0commented, Jun 7, 2018

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:

<Router>
  <Scene key="1" />
  <Drawer key="drawer">
    <Scene key="2" initial={true} />
  </Drawer>
</Router>

Then do Actions.1(), to go from 2 -> 1, then Actions.popTo(2) and it fails.

Cheers

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found