Do not prevent POP transitions based on startingIndex
greenimpala opened this issue · 3 comments
@Traviskn Hey! Just trying to understand the motivation for preventing transitions if the current index is less than the starting index. If we perform any history.replace()
and then history.go(-n)
we end up out of sync with our startingIndex
and subseqently block the back transition!
Is there a chance we could remove this or is there good reason for this?
The main issue I was trying to solve with the starting index was to know if I should allow swipe to go back.
The situation I was imagining is you have something like a login screen. After logging in, you push to the main screen of your app which has a Stack component. You wouldn't want the user to swipe back to go to the login screen, only logging out would navigate you back to the first route. So in this case the Stack allows swiping back only through the routes that it pushed onto the route stack.
A related problem I was hoping to solve is on which screens to show a back button in the header. Unfortunately I haven't had much time recently to finish a transitioning header for the stack 😞 but I imagined I could use the starting index to know if I should show a back button in the header or not.
There's probably a better way to approach this though, totally open to new ideas! Sounds like there are some more dynamic use cases that the "startingIndex" doesn't work well for.
The code that prevents the swipe back gesture if the current route index is less than the starting index is here:
https://github.com/Traviskn/react-router-native-stack/blob/master/lib/StackTransitioner.js#L55
Thanks @Traviskn. Yes I've also spotted it on the pan responder. It absolutely makes sense to 'lock' us into the starting route at the intial index. I may have been too eager to open this issue! Closing for now.