0.0.7 • Published 2 years ago

@doopage/react-facebook-login v0.0.7

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

@doopage/react-facebook-login

Support Login Facebook Component for ReactJS

NPM JavaScript Style Guide

For more related information such as appId, see https://developers.facebook.com/docs/facebook-login/web/

Install

npm install --save @doopage/react-facebook-login

or

yarn add @doopage/react-facebook-login

Usage

import FacebookLogin from '@doopage/react-facebook-login'
import { Button } from "@doopage/react-ui-kit";

const Example = () => {
  const responseFacebook = (response) => {
    console.log("responseFacebook", response);
    // do something
  }

  return (
    <FacebookLogin
      appId={'YOUR_FB_APP_ID'}
      callback={responseFacebook}
      fields="name,email,picture"
      scope="public_profile,email,pages_messaging_subscriptions"
    >
      {({ onClick, disabled }) => {
        return (
          <Button
            color="info"
            onClick={onClick}
            disabled={disabled}
          >
            Đăng nhập Facebook
          </Button>
        );
      }}
    </FacebookLogin>)
}

Props

paramsrequiredtypedefaultdescription
appIdxstringprocess.env.FACEBOOK_APP_IDFacebook app id
scopestringpublic_profile,emailpublic_profile, email, user_birthday
fieldsstringname
callbackxfunctionresultFacebookLogin
returnScopesbooleantrue
xfbmlbooleanfalse
cookiebooleanfalse
redirectUristringwindow.location.href
languagestringen_US
isMobilebooleandetected via userAgentuse isMobile of isreact-device-detect to detect
disableMobileRedirectbooleantrueset to true for popup authentication on mobile devices
onFailurefunctionoptional function to separatere the failed init
statestringoptional string to maintain state between the request and callback. This parameter should be used for preventing Cross-site Request Forgery and will be passed back to you, unchanged, in your redirect URI, default is facebookdirect
authTypestringoptional string to change authentication type
responseTypestringoptional string to change response type. Default value is 'code'
versionstringGraph API version, default is 9.0

License

MIT © Huynh Huy Hiep