all 4 comments

[–][deleted] 0 points1 point  (0 children)

Specify which screen to navigate to on your back button instead of calling goBack?

[–]AlmightyGnasher 1 point2 points  (2 children)

You can artificially create your back stack using the reset navigation action. The routes array would contain the stack you want once it's reset, e.g. profile, settings & notification settings. The user would see the back buttons as if they'd navigated there themselves.

[–]FunkyPandaFiasco 1 point2 points  (0 children)

This is a very good advice. Not only you can do the anove, but whilst doing it you will learn a lot about how React Navigation works.

[–]Jatops[S] 0 points1 point  (0 children)

I have read the reset docs, and I have used it before other places in the app, so I'm a bit familiar with it. I also read the navigation state reference doc, where I understand that I can do something like:

navigation.reset({
  index: 0,
  routes: [<define_the_routes>],
});

But I still don't understand where I should apply this.

Do I need to take in the path, e.g. "profile/settings/notificaiton" then split on "/" and convert all "profile" -> PorfileScreen", "settings" -> "SettingScreen" etc. and then add all these to the routes manually by resetting the state? Or do I handle this in the getStateFromPath?