React navigation back to initial screen in stack

Viewed 314

I have tabbat stack.

<Tab.Navigator tabBar={tabBar} initialRouteName={TABS.FIRST}>
  <Tab.Screen name={TABS.FIRST} component={FirstStackNavigator} />
  <Tab.Screen name={TABS.SECOND} component={SecondStackNavigator} />
  <Tab.Screen name={TABS.THIRD} component={ThirdStackNavigator} />
</Tab.Navigator>

I also a stack for each screen.

  <ThirdStack.Navigator headerMode="none" initialRouteName={ROUTES.PROFILE}>
    <ThirdStack.Screen name={ROUTES.PROFILE} component={Profile} />
    <ThirdStack.Screen name={ROUTES.SETTINGS} component={Settings} />
    <ThirdStack.Screen name={ROUTES.RESULT} component={Result} />
  </ThirdStack.Navigator>

I go from the SECOND stack, to the SETTINGS screen in THIRD stack and in the Settings component I have a CLOSE button, by clicking on which I want to return to the first screen of my current PROFILE stack. I've tried options with goBack(), popToTop() ..., but nothing seems to work. I either go back to the first tab in FIRST stack or the previous stack.

0 Answers
Related