2017-05-27 63 views
4

我想要按照這裏的指南: https://developers.facebook.com/docs/react-native/login 要獲取Facebook登錄工作在我的應用程序。我從字面上複製並粘貼簡單的版本爲這樣的文件:使用React-native實現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模擬器以下錯誤:

無法從{redacted}/node_modules/react-native-fbsdk/js/FBLikeView.js解析模塊prop-types:模塊中不存在模塊映射或在這些目錄中: {project}/node_modules

有關如何繼續的任何想法?

我試着重新安裝節點模塊並重置緩存,但我似乎被阻止。

回答

4

我能夠通過安裝道具類型,以解決此問題:

$ NPM安裝--save道具類型

+0

像工作魅力!感謝隊友 –

+0

它也適用於我。謝謝! –