'IOS Swipe Back gesture does not perfom navigation.goBack()

I have a drawer navigator with many child navigators. On Android, both Header back arrow and navigation bar back button work and go back to previous screens. E.g., if I navigate to a bScreen1 through the drawer, both buttons get me back to the Home Screen of the App i.e. aScreen1

On IOS, Header back arrow work fine, HOWEVER, swipe back gets me back to my login screen inside the AuthNavigator instead of aScreen1, which has 0 sens to me because it is outside the drawerNavigator, and at the same level inside the RootNavigator. The swipe back does not perform a navigation.goBack().

I have already tried overriding the swipe behavior by adding a listener on 'beforeRemove' event and then calling navigation.goBack(), but the wrong screen still shows up for a instant before moving to the right one (previous one)

...
import { createDrawerNavigator } from '@react-navigation/drawer'
import { createStackNavigator } from '@react-navigation/stack';

const DrawerNavigator = createDrawerNavigator();
const rootStack = createStackNavigator();

...
drawerNavigator() {
 return (
  <DrawerNavigator.Navigator>
    <DrawerNavigator.Screen component={aNavigator} />
    <DrawerNavigator.Screen component={bNavigator} />
    ...
    <DrawerNavigator.Screen component={zNavigator} />
  </DrawerNavigator.Navigator>
)}

aNavigator() {
return (
  <ANavigator.Navigator>
    <ANavigator.Screen component={aScreen1} />
    ...
    <ANavigator.Screen component={aScreen10} />
  </ANavigator.Navigator>
)}

bNavigator() {
return (
  <ANavigator.Navigator>
    <ANavigator.Screen component={bScreen1} />
    ...
    <ANavigator.Screen component={bScreen10} />
  </ANavigator.Navigator>
)}


 <rootStack.Navigator initialRouteName="AuthNavigator" screenOptions={{ headerShown: false }}>
       <rootStack.Screen name="AuthNavigator" component={createAuthNavigator} />
       <rootStack.Screen name="DrawerNavigator" component={drawerNavigator} />
</rootStack.Navigator>

Ps: I am using all the latest versions of navigation packages



Solution 1:[1]

I had the same issue when I set animationEnabled: false, if you set it to true you should be able to swipe to switch screens.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 man517