React-native-router-flux: any plans to support SwitchNavigator or recommended setup

Created on 16 Aug 2018  路  5Comments  路  Source: aksonov/react-native-router-flux

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?

feature request

Most helpful comment

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

All 5 comments

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.

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

Keeping it opened to see if someone might implement it.

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

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

Was this page helpful?
0 / 5 - 0 ratings