I have a kind of complex navigation architecture with a Drawer Navigation at the top after a login (handled through a switchNavigator).
something like this -
DrawerNavigator ->
DashboardStack
- Dashboard Screen
- Search Screen
ProjectStack
- ProjectsList Screen
- RecordsList Screen
- RecordDetails Screen
So to search for a record, I go to my search screen (Level 2 of DashboardStack). I search a record, receive a list from backend and then show a list of them. On clicking an item in the list, I need to reach the RecordDetailsScreen with the relevant props (Level 3 of ProjectStack).
This is currently working for me, but when a user presses the back button on android or swipes back on iOS, react-navigation's default behaviour takes me back to the start of my current stack, i.e. ProjectsList Screen (Level 1 of ProjectStack). While, as an end user, I would have expected it to go to the SearchScreen.
I am using react-navigation: 4.1.1 in my project.
Any leads on how I can remember the previous screen from where I came to the present screen would be great.
PS - needless to say, I have other ways to get to the RecordDetailsScreen as well (so cannot default the behaviour to go back to the SearchScreen).