1.0.7 • Published 5 years ago

react-use-fb-login v1.0.7

Weekly downloads
11
License
MIT
Repository
-
Last release
5 years ago

useFacebookLogin for React Hooks

useFacebookLogin allows you to use the latest React Hook to login / logout using Facebook Logins.

Installation

npm install react-use-fb-login --save

Fork

https://github.com/silver-xu/react-use-fb-login

Issue tracking

https://github.com/silver-xu/react-use-fb-login/issues

Usage:

import React from "react";
import { useFacebookLogin } from "react-use-fb-login";

const App = () => {
  const facebookProps = {
    appId: "566204683881459",
    language: "EN",
    version: "3.1",
    fields: ["id", "email", "name"],
    onFailure: error => {
      console.log(error);
    }
  };
  const [{ loaded, currentUser, isLoggedIn }, login, logout] = useFacebookLogin(
    facebookProps
  );

  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        {loaded ? (
          currentUser ? (
            <div>Currently logged in as: {currentUser.name}</div>
          ) : (
            <div>Not logged in</div>
          )
        ) : (
          <div>Retrieving User from Facebook...</div>
        )}
        <br />
        {loaded ? (
          isLoggedIn ? (
            <button onClick={logout}>Logout</button>
          ) : (
            <button onClick={login}>Login</button>
          )
        ) : null}
      </header>
    </div>
  );
};

export default App;

I appreciate my wife to letting me using our precious family time to work on this project.

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago