首页 > 解决方案 > React Native null 不是一个对象(评估'LoginManager.logInWithPermissions')

问题描述

当我尝试登录 Facebook 时,它给了我这个错误

TypeError: null is not an object (evaluating 'LoginManager.logInWithPermissions')
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
at node_modules/react-native/Libraries/Core/ExceptionsManager.js:171:19 in handleException
at node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
at node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:12:21 in ErrorUtils.setGlobalHandler$argument_0
at [native code]:null in flushedQueue
at [native code]:null in invokeCallbackAndReturnFlushedQueue

在此处输入图像描述 在此处输入图像描述

我这样调用函数:

import {View} from "react-native";
import React, { useState } from "react";
import {
  LoginManager,
} from "react-native-fbsdk-next";


               <View style={styles.horisontalView}>
                  <TouchableOpacity
                    onPress={() => {
                      LoginManager.logInWithPermissions([
                        "public_profile",
                        "email",
                      ]).then(
                        function (result) {
                          if (result.isCancelled) {
                            console.log("Cancelado");
                          } else {
                            console.log(
                              "Login realizado con permisos: " +
                                result.grantedPermissions.toString()
                            );
                          }
                        },
                        function (error) {
                          console.log("Error en Login: " + error);
                        }
                      );
                    }}
                  >
                  </TouchableOpacity>
              </View>

按照以下说明安装:https ://www.npmjs.com/package/react-native-fbsdk-next

标签: react-nativeexpofacebook-login

解决方案


推荐阅读