react-fb-login
Description
A higher order component to help you using the Facebook login plugin, using React.js.
Install
npm i react-fb-login
Props
Props | Type | Required | Default Value |
---|---|---|---|
appId | string | yes | - |
autoLoad | boolean | no | true |
fbCSS | object | no | object |
scope | string | no | 'public_profile' |
cookie | boolean | no | false |
language | string | no | navigator.language |
redirect_uri | string | no | location.href |
version | string | no | 'v3.0' |
xfbml | boolean | no | false |
loginCb | function | yes | - |
notLoginCb | function | no | undefined |
clickCb | function | no | undefined |
Example
In the Github repo there is an example where you can run the component.
/*********** FILE App.js ***********/;; const Home = <div> <span>Home</span> </div>; state = logged: false ; { document; } { const logged = thisstate; return !logged ? <LoginButton/> : <Home/>; } ;
/*********** FILE MyLoginButton.js ***********/;; const params = appId: 'your_facebook_app_id' scope: 'public_profile' cookie: false language: 'en_US' version: 'v3.0' xfbml: true const onFbLoginEvent = { const fbLoginEvent = 'onFbLogin'; document;} const loginCb = { console; ;}; const notloginCb = { console;}; const settings = params loginCb notloginCb; @ { return <button style=thispropsfbCSS> Login </button> ; }
License
This code has MIT license.