'goBack() automatically triggers while moving from drawer to stack in nested navigator react-native

I am trying to reach PatientDetails screen, For the first time after starting the app it behaves abnormally(navigating to patientdetails screen and automatically coming back to dwawer navigator), after one abnormal behaviour everything works fine, Same problem is facing in every case of navigating from drawer to stack navigator I am not getting any error in console.....

Any solution for this problem?

const MainNavigator = (props) => {
    return (
        <NavigationContainer>
            <Stack.Navigator
                screenOptions={{ headerShown: false }}
            >
                <Stack.Screen name='StackNavigator' component={StackNavigator} />
                <Stack.Screen name='DrawerNavigator' component={DrawerNavigator} />
                <Stack.Screen name='AddPatient' component={AddPatient}
                    options={{
                        headerShown: true,
                        headerTitle: "Add Patient",
                        headerTitleStyle: { color: Colors.white },
                        headerStyle: { height: constants.headerHeight, backgroundColor: Colors.splashScreen },
                        headerBackTitleVisible: false,
                        headerTintColor: Colors.white
                    }}
                />
                <Stack.Screen name='Notification' component={Notification}
                    options={{
                        headerShown: true,
                        headerTitle: "Notification",
                        headerTitleStyle: { color: Colors.white },
                        headerStyle: { height: constants.headerHeight, backgroundColor: Colors.splashScreen },
                        headerBackTitleVisible: false,
                        headerTintColor: Colors.white
                    }}
                />
                <Stack.Screen name='PatientDetails' component={PatientDetails}
                    options={{
                        headerShown: true,
                        headerTitle: "Patient Details",
                        headerTitleStyle: { color: Colors.white },
                        headerStyle: { height: constants.headerHeight, backgroundColor: Colors.splashScreen },
                        headerBackTitleVisible: false,
                        headerTintColor: Colors.white
                    }}
                />
            </Stack.Navigator>
        </NavigationContainer>
    )
}


Sources

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

Source: Stack Overflow

Solution Source