1

My code is similar to following. suppose currently my navigation stack history is:

Screen A> Screen B> Screen D.

From screen D on a button press I want to reset my navigation stack state/history like the follwing: Screen A> Screen F

But I am getting this error:

  The action 'RESET' with payload {"index":1,"routes":[{"name":"Screen A"},{"name":"Screen F"}]} was not handled by any navigator.
<Stack.Navigator>
  <Stack.Screen name="TabNavigator" component={TabNavigator} />
  <Stack.Screen name="Screen E" component={ScreenE} />
  <Stack.Screen name="Screen F" component={ScreenF} />
  <Stack.Screen name="Screen G" component={ScreenG} />
</Stack.Navigator>
<Tab.Navigator>
  <Tab.Screen name="Screen A" component={ScreenA} />
  <Tab.Screen name="Screen B" component={ScreenB} />
  <Tab.Screen name="Screen C" component={ScreenC} />
  <Tab.Screen name="Screen D" component={ScreenC} />
</Tab.Navigator>

const ScreenD=({navigation})=>{ <Button title="reset stack" onPress={()=> navigation.reset({
        index: 1,
         routes: [{ name: "Screen A" }, { name: "Screen F" }],
       })} /> }
7

1 Answer 1

1

use CommonActions.reset() from here https://reactnavigation.org/docs/navigation-actions

This Worked well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.