Pankaj Chaturvedi
Pankaj Chaturvedi

Reputation: 208

How to destroy current screen and navigate to another screen ? so that on back press that previous screen doesn't appear

Hello everyone i am new to react-native and stuck in a navigation problem. i have crawled through every question about this but found nothing helpful.

I have Navigation structure like this

Tab Navigator

  1. HomeStack [mainScreen,Screen2]

  2. PostStack[cameraScreen,UploadPostScreen]

Now i want to navigate to MainScreen of HomeStack after uploading the Post and along with that i want to remove these post and upload screen so that i can not go back by pressing back button.

Upvotes: 1

Views: 2936

Answers (2)

Deepak Singh
Deepak Singh

Reputation: 1145

in my case,

I have just used

props.navigation.reset({
  index: 0,
  routes: [
    {
      name: 'Login'
    }
  ]
});

Upvotes: 1

Stas  Kravchuk
Stas Kravchuk

Reputation: 146

You need to use replace method in that case, take a look here:

https://reactnavigation.org/docs/stack-actions/#replace

Upvotes: 5

Related Questions