Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

login with facebook in react

// import book from '../../assets/images/facebook.png'
import './assets/css/all.css'
import './assets/css/bootstrap.min.css'
import './assets/css/responsive.css'
import './assets/css/style.css'
import React, { useState } from "react";
import FacebookLogin from "react-facebook-login/dist/facebook-login-render-props";
const book = require("./assets/images/facebook.png")
//import ReactDOM from "react-dom";
const responseFacebook = (response) => {
  console.log(response);
};
const FacebookLoginPage = () => {
  
  const [showLoginButton, setLoginButton] = useState(true);
  const [showLogoutButton, setLogoutButton] = useState(false);
  const loginHandler = (res) => {
    console.log("res", res.profileObj);
    setLoginButton(false);
    setLogoutButton(true);
  };
  const failureHandler = (res) => {
    console.log("login failed", res);
  };
  const logoutHandler = (res) => {
    alert("logout sucessfully");
    setLoginButton(true);
    setLogoutButton(false);
  };
  return (
    <>
      {showLoginButton && (
        <FacebookLogin
          appId="240813111599696"
          callback={responseFacebook}
          render={(renderProps) => (
            <button
              className="btn button btn-outline"
              onClick={renderProps.onClick}
            >  
                  <img src={book} />  Sign up with Facebook
            </button>
            
            )}
            />
            )}
           
    </>
  );
};
export default FacebookLoginPage;
 
PREVIOUS NEXT
Tagged: #login #facebook #react
ADD COMMENT
Topic
Name
3+2 =