1.1.0 • Published 8 years ago

react-fb-auth v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

React Facebook Authentication

Component for facebook authentication based on this repository

Example

import React from 'react';
import ReactDOM from 'react-dom';
import FacebookAuth from 'react-fb-auth';

const response = (response) => {
  console.log(response);
}

const fbBtn = ({onClick}) => {
    return <button onClick={onClick}>Login with facebook</button>
}

ReactDOM.render(
  <FacebookAuth
    appId="1032595931187376"
    autoLoad={true}
    fields="name,email,picture"
    component={fbBtn}
    callback={response} />,
  document.getElementById('demo')
);

Component example

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

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

      this.response = this.response.bind(this);
  };

  response(response) {
    // Send the token to the server and link the account
    console.log(response);
  };

  render() {
    return (
      <FacebookLogin
        appId="1099597531133376"
        component={({onClick}) => {
            return <button onClick={onClick}>Login with facebook</button>
        }}
        fields="name,email,picture"
        callback={this.response}
      />
    )
  }
}

export default MyComponent;

Parameters

paramsvaluedefault value
appIdstringRequired
scopestringpublic_profile, email, user_birthday
fieldsstringname,email,picture
callbackfunctionresultFacebookLogin
autoLoadbooleanfalse
xfbmlbooleanfalse
reAuthenticatebooleanfalse
btnTextstringThe text of the button
btnClassNamestringClass name for the default button
versionstring2.3
languagestringen_US
componentfunctionThe button used for the auth