source: node_modules/react-facebook-login/README.md@ 47f4eaf

Last change on this file since 47f4eaf was 47f4eaf, checked in by Marko <Marko@…>, 20 months ago

Final features implemented

  • Property mode set to 100644
File size: 6.7 KB
Line 
1# React Facebook Login - [![Build Status](https://travis-ci.org/keppelen/react-facebook-login.svg?branch=master)](https://travis-ci.org/keppelen/react-facebook-login)
2
3> A Component React for Facebook Login
4
5## Getting Started
6
7- `yarn add react-facebook-login` or `npm install react-facebook-login`
8- Your application will also need `react-dom` and `react` installed.
9
10## Development
11
12```shell
13git clone https://github.com/keppelen/react-facebook-login.git && cd react-facebook-login
14npm install react react-dom react-facebook-login --save --force
15npm start
16```
17- navigate to [localhost:8080](http://localhost:8080)
18
19## How to use
20
21### Basic button with styling
22
23```js
24import React from 'react';
25import ReactDOM from 'react-dom';
26import FacebookLogin from 'react-facebook-login';
27
28const responseFacebook = (response) => {
29 console.log(response);
30}
31
32ReactDOM.render(
33 <FacebookLogin
34 appId="1088597931155576"
35 autoLoad={true}
36 fields="name,email,picture"
37 onClick={componentClicked}
38 callback={responseFacebook} />,
39 document.getElementById('demo')
40);
41```
42
43### Facebook button without styling
44
45If you're providing all your own custom styling, you can use the render prop build. This build doesn't include any CSS or additional code needed to customise the look of the button, and instead leaves that entirely up to you. You can see an example of this in `demo/index.js`.
46
47To make sure you import the right version, you will need to update your import line:
48
49```js
50import FacebookLogin from 'react-facebook-login/dist/facebook-login-render-props'
51```
52
53```
54<FacebookLogin
55 appId="1088597931155576"
56 autoLoad
57 callback={responseFacebook}
58 render={renderProps => (
59 <button onClick={renderProps.onClick}>This is my custom FB button</button>
60 )}
61/>
62```
63
64The `render` function will be passed the following properties for you to use:
65
66- `onClick`
67- `isDisabled`
68- `isProcessing`
69- `isSdkLoaded`
70
71
72### Custom CSS Class and Icon
73
74By default fontawesome is included, If you don't want to use default fontawesome icons, you can send an element in icon attribute
75
76Fontawesome example:
77```js
78
79import React from 'react';
80import ReactDOM from 'react-dom';
81import FacebookLogin from 'react-facebook-login';
82
83const responseFacebook = (response) => {
84 console.log(response);
85}
86
87ReactDOM.render(
88 <FacebookLogin
89 appId="1088597931155576"
90 autoLoad={true}
91 fields="name,email,picture"
92 callback={responseFacebook}
93 cssClass="my-facebook-button-class"
94 icon="fa-facebook"
95 />,
96 document.getElementById('demo')
97);
98```
99
100Custom element example:
101```js
102
103import React from 'react';
104import ReactDOM from 'react-dom';
105import FacebookLogin from 'react-facebook-login';
106import TiSocialFacebookCircular from 'react-icons/lib/ti/social-facebook-circular';
107
108const responseFacebook = (response) => {
109 console.log(response);
110}
111
112ReactDOM.render(
113 <FacebookLogin
114 appId="1088597931155576"
115 autoLoad={true}
116 fields="name,email,picture"
117 callback={responseFacebook}
118 cssClass="my-facebook-button-class"
119 icon={<TiSocialFacebookCircular />}
120 />,
121 document.getElementById('demo')
122);
123```
124
125### Custom permission
126By default the component, request only 'public_profile' permission, you can change if you send 'scope', that is a string comma separated attribute.
127
128see https://developers.facebook.com/docs/facebook-login/permissions for permissions list
129
130```js
131 import React from 'react';
132 import FacebookLogin from 'react-facebook-login';
133
134 class MyComponent extends React.Component {
135 responseFacebook(response) {
136 console.log(response);
137 }
138
139 render() {
140 return (
141 <FacebookLogin
142 appId="1088597931155576"
143 autoLoad={true}
144 fields="name,email,picture"
145 scope="public_profile,user_friends,user_actions.books"
146 callback={this.responseFacebook}
147 />
148 )
149 }
150 }
151
152 export default MyComponent;
153```
154
155### Server
156```js
157'use strict';
158
159import React from 'react';
160import FacebookLogin from 'react-facebook-login';
161
162class MyComponent extends React.Component {
163 responseFacebook(response) {
164 console.log(response)
165 }
166
167 render() {
168 return (
169 <FacebookLogin
170 appId="1088597931155576"
171 autoLoad={true}
172 fields="name,email,picture"
173 callback={this.responseFacebook}
174 />
175 )
176 }
177}
178
179export default MyComponent;
180```
181
182
183## Parameters
184
185| params | value | default value |
186|:------------:|:-------------------:|:---------------------------------------------------:|
187| appId | string | Required |
188| size | string | small - medium - metro |
189| scope | string | public_profile, email, user_birthday |
190| fields | string | name,email,picture |
191| callback | function | resultFacebookLogin |
192| returnScopes | boolean | false |
193| autoLoad | boolean | false |
194| xfbml | boolean | false |
195| cookie | boolean | false |
196| textButton | string | Login with Facebook |
197| cssClass | string | kep-login-facebook kep-login-facebook-[button-size] |
198| redirectUri | string | window.location.href (mobile-only) |
199| version | string | 2.3 |
200| icon | string|element | none |
201| language | string | en_US |
202| onClick | function | Initial click on the component |
203| isMobile | boolean | detected via userAgent |
204| isDisabled | boolean | undefined |
205| tag | string | HTML Element, Ex: 'a', 'button' |
206| onFailure | function | optional function to separatere the failed init |
207| state | string | optional 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 |
208| authType | string | optional string to change authentication type |
209| responseType | string | optional string to change response type. Default value is 'code' |
Note: See TracBrowser for help on using the repository browser.