2017-05-05 7 views
0

私はreact-facebook-login packageを使ってReactJSにFacebookログインボタンを実装しようとしています。提供されたコードを使用するのは非常に簡単です。ReactJS Facebookのログインはリアフェイスブックログインパッケージを使用しています

しかし、ユーザーがログインしても有効なトークンがまだ残っている場合、ボタンは変更されずに「ログイン」されたままになります。

ButtonFacebookLogin.js:18

Object {name: "John Doe", picture: Object, id: "101560159xxxxxxx", 
accessToken: "EAAFdByROZC…5tDST3sxnhZASZBZ", userID: "101560159xxxxxxxx"…} 
私はにconsole.logに 名前IDaccessTokenユーザーIDを含む応答を見ることができます

ReactJSスクリプト内のコードを変更して有効なログインがあったかどうかを確認する必要があります可能?私はReactJS :-)に新しいですし、私はこのFacebookログインボタンパッケージのドキュメントをたくさん見つけることができなかったとして

import React from 'react'; 
import FacebookLogin from 'react-facebook-login'; 

class ButtonFacebookLogin extends React.Component { 
    constructor(props) { 
    super(props); 

    this.responseFacebook = this.responseFacebook.bind(this); 
    this.user = null; 
    }; 

    responseFacebook(response) { 
    console.log(response); 
    this.user = response.name; 
    console.log(this.user); 
    }; 

    componentClicked(response) { 
    console.log(response); 
    }; 

    render() { 
    return (
     <FacebookLogin 
     appId="383760232021913" 
     autoLoad={true} 
     fields="name,email,picture" 
     scope="public_profile,user_friends" 
     onClick={this.componentClicked} 
     callback={this.responseFacebook} 
     /> 
     // just here above the button always looks the same 
    ) 
    } 

申し訳ありませんが、質問は愚かに聞こえるかもしれません。

答えて

0

はい、すでにログインしているかどうかを確認して、FacebookLoginコンポーネントのtextButtonフィールドを変更する必要があります。

関連する問題