使用React-native实现Facebook登录的问题

时间:2017-05-27 12:13:14

标签: ios facebook reactjs react-native facebook-javascript-sdk

我正在尝试按照此处的指南: https://developers.facebook.com/docs/react-native/login 让facebook登录我的应用程序。我已经将简单版本复制并粘贴到这样的文件中:

    import React, { Component } from 'react';
import{
  View
} from 'react-native';

const FBSDK = require('react-native-fbsdk');
const {
  LoginButton,
} = FBSDK;

var Login = React.createClass({
  render: function() {
    return (
      <View>
        <LoginButton
          publishPermissions={['publish_actions']}
          onLoginFinished={
            (error, result) => {
              if (error) {
                alert('Login failed with error: ' + result.error);
              } else if (result.isCancelled) {
                alert('Login was cancelled');
              } else {
                alert('Login was successful with permissions:'  + result.grantedPermissions)
              }
            }
          }
          onLogoutFinished={() => alert('User logged out')}/>
      </View>
    );
  }
});
export default class FacebookLogin extends Component {
render(){
  return (
    <Login />
  );
}

}

但是在ios模拟器上收到以下错误:

无法从prop-types解析模块{redacted}/node_modules/react-native-fbsdk/js/FBLikeView.js:模块映射或这些目录中不存在模块: (项目)/ node_modules

关于如何进行的任何想法?

我尝试重新安装节点模块并重置缓存但我似乎被阻止了。

2 个答案:

答案 0 :(得分:4)

我能够通过安装prop-types来解决这个问题:

$ npm install --save prop-types

答案 1 :(得分:0)

PropTypes现在是一个单独的模块,不再包含在反应中。这是链接:https://www.npmjs.com/package/prop-types

更多信息:https://github.com/GeekyAnts/NativeBase/issues/861