You cannot navigate to a screen outside the current navigator like that.
It is recommended that you use the authentication flow in the react navigation docs here: https://reactnavigation.org/docs/auth-flow
It uses conditional operations to change the navigator, instead of directly navigating to a screen.
For Example:
isSignedIn ? (
<>
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Profile" component={ProfileScreen} />
<Stack.Screen name="Settings" component={SettingsScreen} />
</>
) : (
<>
<Stack.Screen name="SignIn" component={SignInScreen} />
<Stack.Screen name="SignUp" component={SignUpScreen} />
</>
)
Source: https://reactnavigation.org/docs/auth-flow#how-it-will-work
CLICK HERE to find out more related problems solutions.