I am new to React native and I try to redirect after Facebook login bu I get the Invalid hook call. Hooks can only be called inside of the body of a function component
. I Here is my code. Please give me some help with the issue. The login works until I try to use useNavigation().
export default function LoginScreen({ path }: { path: string }) { return (<Container style={styles.container} ><FormControl><Button style={styles.loginButton} onPress={FacebookLogin}><Text style={styles.textButton}>Login with Facebook</Text></Button></FormControl></Container> );}async function FacebookLogin(){ try { await Facebook.initializeAsync({ appId: '...', }); const data = await Facebook.logInWithReadPermissionsAsync({ permissions: ['public_profile'], }); if (data.type === 'success') { const response = await fetch(`https://graph.facebook.com/me?access_token=${(data.token)}`); //type authScreenProp = StackNavigationProp<RootStackParamList, 'Dashboard'>; // const navigation = useNavigation<authScreenProp>(); //rconsole.log(await response.json()); Alert.alert('Logged in!', `Hi ${(await response.json()).name}!`); const navigation = useNavigation(); navigation.navigate('Dashboard'); } else { // type === 'cancel' } } catch ({ message }) { alert(`Facebook Login Error: ${message}`); }}