react-router-native-stack
react-router-native-stack copied to clipboard
Navigate to the previous scroll position when navigating back
I'm using scroll views and when the user scrolls to the end of a scroll, clicks a link, goes to a next screen and navigates back to the first scroll view, the position that he is is not the same as it was before navigating forward. One would expect the position would be the same, and not at the top of the scroll view. I'm trying to fix this by inspecting the position the user is anytime they scroll so when they navigate back I automatically scroll to this position but the effect is not so nice. Any ideas on how can I make this run smoothly ?
Oh dang that does sound like a problem, it sounds like this is a reason for keeping routes in the stack mounted rather than un-mounting them when a new route pushes in.
I'm not sure of a better fix in the meantime, but I can look into keeping routes in the stack mounted so that they don't lose their state (or scroll position in this case)
I agree, it is better to keep routes mounted so they don't lose their state. Losing scrolling position is a bad for UX, but actual bugs comes because of losing states of unmounted pages and their child components.
@Traviskn I agree that keeping routes mounted makes more sense. This is why even native components like UINavigationController on iOS keep their UIViewControllers mounted after a push. Otherwise, you close off the user from being able to properly use callbacks or delegation pattern in their apps. Any ETA on when you'd fix this? Or if you could point me to the code path, I'm happy to make a PR.
Sorry no ETA, I haven't had much time to work on this library recently. Keeping the stack of components in the stack mounted would be a big foundational change to how the StackTransitioner works, so it wouldn't be a quick/easy thing to do. lib/StackTransitioner.js is where I'd recommend looking if you'd like to take a stab at it! I'd be open to PRs implementing this change
Is someone looking into this enhancement?
When can I use it?