简体   繁体   中英

Can't find variable: Expo

I am making an app with react native. It has login with facebook option, it keeps giving me this error. "Facebook Login Error: Can't find variable: Expo" What am I doing wrong here?

Do I have to install some dependencies on Linux

f.auth().onAuthStateChanged(function(user) {
  if(user){
    //logged in
    console.log('Logged in', user);
  }else {
    //logged out
    console.log('logged out');
  }
});



const { type, token} = await Expo.Facebook.logInWithReadPermissionsAsync(
  'APP_ID',
  { permissions: ['email', 'public_profile'] }
);

if(type === 'success'){
  const credential = firebase.auth.FacebookAuthProvider.credential(token);
    firebase.auth().signInWithCredential(credential).catch((error) => {
    console.log('Error...',error);
  })
}








Possible Unhandled Promise Rejection (id:0): ReferenceError: Can't find variable: Expo loginWithFacebook$

You have forgot to import Expo

import Expo from 'expo';

But you should use expo-facebook module for facebook login for more information please read document here https://docs.expo.io/versions/latest/sdk/facebook/

Assuming you have included Facebook SDK as following

import * as Facebook from 'expo-facebook';

You shouldn't be redundantly calling Expo.Facbook but instead try

const { type, token} = await Facebook.logInWithReadPermissionsAsync...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM