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

any plans to support SwitchNavigator or recommended setup #3185

Closed
aniltirola opened this issue Aug 16, 2018 · 5 comments
Closed

any plans to support SwitchNavigator or recommended setup #3185

aniltirola opened this issue Aug 16, 2018 · 5 comments

Comments

@aniltirola
Copy link

Version

Expected behaviour

use the features of SwitchNavigator
https://reactnavigation.org/docs/en/switch-navigator.html

Actual behaviour

seems not to be implemented now

My question

Are there any plans to support SwitchNavigator?
Or are there any recommandations how to implement the behaviour of SwitchNavigator?

@mwskwong
Copy link

mwskwong commented Aug 18, 2018

OK, from the offical doc of react navigation, the key feature of Switch Navigation is

to only ever show one screen at a time. By default, it does not handle back actions and it resets routes to their default state when you switch away.

You may try to look at Actions.reset()
https://github.com/aksonov/react-native-router-flux/blob/master/docs/API.md#actions

which seems like something you are looking for. The downside though is no transition animation will be fired. If you want to keep the animation while simply prevent users going back to the previous page, try back={false} in the corresponding Scene and override the BackHandler (Android only, ios doesn't have a hardware back button) for that particular scene. https://facebook.github.io/react-native/docs/backhandler

You may call Actions.popTo("sceneKey") or Actions.push("sceneKey") in your backhandler and implement onBack in your Scene according to your need.

@aniltirola
Copy link
Author

ok, thanks; currently I solved everything with a customreducer;

@daviscabral
Copy link
Collaborator

Keeping it opened to see if someone might implement it.

@daviscabral daviscabral reopened this Aug 24, 2018
@aksonov
Copy link
Owner

aksonov commented Sep 5, 2018

@aniltirola @daviscabral What is problem just to pass SwitchNavigator as navigator param to container Scene?

@aksonov aksonov closed this as completed Sep 5, 2018
@daviscabral
Copy link
Collaborator

Thanks - I might start a doc page project - to link API with examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants