React-native-router-flux: Disable swiping back only to the spalsh screen

Created on 15 Sep 2018  路  2Comments  路  Source: aksonov/react-native-router-flux

Version

Tell us which versions you are using:

  • react-native-router-flux "^4.0.1"
  • react "16.3.1"
  • react-native "0.55.4"

Expected behaviour

I want to disable the swipe back function only from main screen to splash screen.
And when it comes to other screens, I want the swipe back function to work.

Actual behaviour

I have tried to add gestureEnabled / panHandlers to the parent Scene, but it will disable all the swipe back function.
What I expect is to only disable the swipe back function to spash screen.

Sample Code

<Router> <Scene hideNavBar={true}> <Scene key="splashScreen" component={splashScreen} initial /> <Scene key="mainScreen" title="main" hideNavBar={true} > <Scene key="main1" component={main1} /> <Scene key="main2" component={main2} /> </Scene> </Scene> </Router>
I want to disable swipe back between splashScreen and main1/main2 ,
and enable swipe back between main1 and main2.

for stack overflow question

Most helpful comment

I agree with @LeviWilliams - I believe Splashscreen should not be part of your group of scenes - but a piece of Switch - to be replaced when finish loading - that way there is no back to splash when the app loads - since the scene would be removed from the stack.

Or try to use a type replace - that way it will be also replaced instead of having other scene pushed over.

Let's move this discussion to StackOverflow or the gitter channel - since it suits more there than here. In case if you think this is a bug and need to be really fixed, reopen the issue.

All 2 comments

Only way to do this is using the panHandlers={null} prop. You can _switch up how your scenes are nested_ or only _specify that prop on certain scenes_ to ensure the rest of your application still has the expected swipe back behavior.

I agree with @LeviWilliams - I believe Splashscreen should not be part of your group of scenes - but a piece of Switch - to be replaced when finish loading - that way there is no back to splash when the app loads - since the scene would be removed from the stack.

Or try to use a type replace - that way it will be also replaced instead of having other scene pushed over.

Let's move this discussion to StackOverflow or the gitter channel - since it suits more there than here. In case if you think this is a bug and need to be really fixed, reopen the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sreejithr picture sreejithr  路  3Comments

sarovin picture sarovin  路  3Comments

moaxaca picture moaxaca  路  3Comments

booboothefool picture booboothefool  路  3Comments

GCour picture GCour  路  3Comments