-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Prevent certain scenes in stack from always being mounted? #2254
Comments
All screens in nav stack must be mounted, it is by design for any navigation. You really need to rethink your architecture. I'd just catch exception for non-exist ID (i.e. render empty screen) and do 'double' pop after item removing. |
Another option is to 'reset' whole stack to |
Hey Pavel, thanks for your replies! I do currently pop twice in an attempt to navigate back two screens after deleting the item. The code snippet I posted above should catch if the list exists or not (since that scene is still mounted before/after the deletion) but the component still renders before pop() happens. As for the reset - how would you recommend handling this? I have As far as architecture, I'll probably rework it as you suggested. Instead of deleting the item immediately, I'll throw it into a queue and resolve the queue once I've reached the initial scene in the stack after |
Yes, it seems to be good idea - I think you could just try |
Sounds good. Alternatively, I've begun to check if certain props exist in |
Hey folks!
Question:
Is it possible to prevent certain scenes in the nav stack from always being mounted?
This question has been asked before, but was considered "closed" once V3 became obsolete; however, I'm still seeing this behavior without any viable solutions.
I've got a few scenes in a todo-like app. The hierarchy looks like:
Lists -> List Todos -> List Options.
On the List Options scene, you have the ability to delete the list. Upon doing so, I send you back to the Lists scene (which is 2 scenes back). However, the List Todos, being still mounted in the stack, tries to pull in props from the now non-existent list, and therefore throws errors.
This would not be the case if previous stack scenes became unmounted. I try to catch this error before the component is updated like so, but to no avail:
componentWillReceiveProps(nextProps) { if (!nextProps.currentList) { console.log('NO LIST'); Actions.pop(); } }
I have been racking by brain over this the past few days. This behavior doesn't seem right, but the current RNRF framework doesn't allude to supporting anything like this. It would be very helpful.
On the other hand, I'm open to rethinking my code architecture if that is the issue. I am at a complete production standstill, so any advice is welcome. Thank you!
Versions:
"react-native": "0.45.1",
"react-native-router-flux": "^4.0.0-beta.17",
The text was updated successfully, but these errors were encountered: