ReferenceError: facebook is not defined : can't connect with facebook login React Native
Posted
技术标签:
【中文标题】ReferenceError: facebook is not defined : can\'t connect with facebook login React Native【英文标题】:ReferenceError: facebook is not defined : can't connect with facebook login React NativeReferenceError: facebook is not defined : can't connect with facebook login React Native 【发布时间】:2020-10-22 08:23:26 【问题描述】:我从 React native 开始,我尝试使用 expo-facebook 来连接用户(我正在关注 youtube 上的教程)
最后得到这个消息:ReferenceError: facebook is not defined
**AuthScreen ../user/jobs/screen/users/AuthScreen.js:10 7 | // 创建一个组件 8 | const AuthScreen = (props) => 9 |
10 |脸书=异步()=> 11 |常量 类型,令牌 = 等待 Facebook.logInWithReadPermissionsAsync("xxxx", 12 |权限:“public_profile” 13 | )**
这是代码:
import React, Component from 'react';
import View, Text, StyleSheet, Button from 'react-native';
import * as Facebook from 'expo-facebook'
import * as firebase from 'firebase'
const AuthScreen = (props) =>
facebook = async () =>
const type, token = await Facebook.logInWithReadPermissionsAsync("xxxx",
permission:"public_profile"
)
if(type == "success")
const credential = firebase.auth.FacebookAuthProvider.credential(token)
firebase.auth().signInWithCredential(credential)
.catch(error =>
console.log(error)
)
props.navigation.navigate('Jobs')
return (
<View style=styles.container>
<Text style=fontSize: 35, textAlign:'center', paddingBottom:8>`Find Jobs or \nSubmit Jobs`</Text>
<View style=paddingHorizontal:30, marginTop:10 >
<Button title="Login with Facebook" onPress=facebook />
</View>
</View>
);
;
export default AuthScreen;
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
谢谢
【问题讨论】:
【参考方案1】:在定义 facebook 变量之前尝试添加 let
let facebook = async()=>...
【讨论】:
谢谢它的工作和页面加载,但我得到另一个:/以上是关于ReferenceError: facebook is not defined : can't connect with facebook login React Native的主要内容,如果未能解决你的问题,请参考以下文章