We have a case when we need to take the screen from deep inside the stack navigator, if it's there, and push it on top of the stack. If screen is not already in the stack, just push it on top (navigate).
I was able to do this by adding
getId={() => 'menu'}
prop to
<Stack.Screen ... />
in our app navigator, to prevent more than one 'menu' screen in the stack, and then calling
navigation.dispatch(StackActions.push('menu'))
. The problems with this approach are
  1. doesn't animate the transition to 'menu' when it's already in the stack
  2. requires special AppNavigator configuration with
    getId
    prop
It would be nice to have it working (always with animation) with just one line of code
navigation.dispatch(StackActions.drawToTop('menu'))
Thanks in advance!