Skip to content
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

Nested Screen Infinite Loop #566

Closed
velkymx opened this issue Feb 24, 2020 · 4 comments · Fixed by #589
Closed

Nested Screen Infinite Loop #566

velkymx opened this issue Feb 24, 2020 · 4 comments · Fixed by #589
Assignees
Labels
bug Something isn't working

Comments

@velkymx
Copy link
Contributor

velkymx commented Feb 24, 2020

Steps to Reproduce:

Have 2 screen calling each other with the nested controller
(screen A calls B, Screen B call A)

Go to screen preview

Current Behavior:
The screens loop over each other indefinitely

https://www.dropbox.com/s/dqqmbylgpschjr8/loopingNested.mp4?dl=0

@velkymx velkymx added the bug Something isn't working label Feb 24, 2020
@velkymx
Copy link
Contributor Author

velkymx commented Feb 24, 2020

I'm open to ideas on how to solve this issue.

@chipit24
Copy link
Contributor

@velkymx We've thought of a possible solution to this called the "my child cannot be one of my ancestors". Each Nested Screen component will climb up its parent tree and collect the name of all it's parent screens. If the screen it wants to render is contained in this list, it won't render, preventing a possible cycling / infinite loop.

This would render all the screens up but not including the screen that would cause an infinite loop.

Using your example, Screen A would call Screen B, but before the nested screen component renders its referenced screen, it will ask itself, "is my parent the same as my child?" And if so, it won't render its child.

@velkymx
Copy link
Contributor Author

velkymx commented Feb 25, 2020

@chipit24 as long as we surface an error message that calls it out.

@chipit24
Copy link
Contributor

The solution we ultimately ended up going with is passing down an array of rendered screens to each nested screen renderer and preventing re-rendering a screen which has already been rendered, thus preventing an infinite loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants