react-es-fb-login 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/README.md +175 -175
- package/dist/types/params.type.d.ts +5 -2
- package/examples/with-client.tsx +56 -56
- package/examples/with-component.tsx +35 -35
- package/package.json +62 -62
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021 greatSumini <greatSumini@gmail.com>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 greatSumini <greatSumini@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,175 +1,175 @@
|
|
|
1
|
-
# React Fb Login
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/react-fb-login)
|
|
4
|
-
[](https://www.npmjs.com/package/react-fb-login)
|
|
5
|
-
[](https://www.npmjs.com/package/react-fb-login)
|
|
6
|
-
[](https://github.com/Evolve-Next/react-facebook-login/actions/workflows/ci.yml)
|
|
7
|
-
[](https://github.com/Evolve-Next/react-facebook-login/actions/workflows/cd.yml)
|
|
8
|
-
[](https://github.com/Evolve-Next/react-facebook-login)
|
|
9
|
-
|
|
10
|
-
<br/>
|
|
11
|
-
|
|
12
|
-
React Component for Facebook Login. aims to improve [react-facebook-login](https://github.com/keppelen/react-facebook-login).<br/>
|
|
13
|
-
[한글 가이드](https://sumini.dev/guide/016-react-facebook-login/)
|
|
14
|
-
|
|
15
|
-
- 💙 Typescript support
|
|
16
|
-
- 📦 6kb mini library
|
|
17
|
-
- 👫 All browsers supported
|
|
18
|
-
- 🏃 Currently maintaining
|
|
19
|
-
|
|
20
|
-
## Table of contents
|
|
21
|
-
|
|
22
|
-
- [React Fb Login](#react-fb-login)
|
|
23
|
-
- [Table of contents](#table-of-contents)
|
|
24
|
-
- [Getting Started](#getting-started)
|
|
25
|
-
- [Usage](#usage)
|
|
26
|
-
- [Component](#component)
|
|
27
|
-
- [FacebookLoginClient](#facebookloginclient)
|
|
28
|
-
- [Examples](#examples)
|
|
29
|
-
- [Props](#props)
|
|
30
|
-
- [Stay in touch](#stay-in-touch)
|
|
31
|
-
- [License](#license)
|
|
32
|
-
- [Links](#links)
|
|
33
|
-
|
|
34
|
-
## Getting Started
|
|
35
|
-
|
|
36
|
-
```shell
|
|
37
|
-
npm i --save react-fb-login
|
|
38
|
-
# or
|
|
39
|
-
yarn add react-fb-login
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Usage
|
|
43
|
-
|
|
44
|
-
### Component
|
|
45
|
-
|
|
46
|
-
```tsx
|
|
47
|
-
import FacebookLogin from 'react-fb-login';
|
|
48
|
-
|
|
49
|
-
// default
|
|
50
|
-
<FacebookLogin
|
|
51
|
-
appId="1088597931155576"
|
|
52
|
-
onSuccess={(response) => {
|
|
53
|
-
console.log('Login Success!', response);
|
|
54
|
-
}}
|
|
55
|
-
onFail={(error) => {
|
|
56
|
-
console.log('Login Failed!', error);
|
|
57
|
-
}}
|
|
58
|
-
onProfileSuccess={(response) => {
|
|
59
|
-
console.log('Get Profile Success!', response);
|
|
60
|
-
}}
|
|
61
|
-
/>
|
|
62
|
-
|
|
63
|
-
// custom style
|
|
64
|
-
<FacebookLogin
|
|
65
|
-
appId="1088597931155576"
|
|
66
|
-
style={{
|
|
67
|
-
backgroundColor: '#4267b2',
|
|
68
|
-
color: '#fff',
|
|
69
|
-
fontSize: '16px',
|
|
70
|
-
padding: '12px 24px',
|
|
71
|
-
border: 'none',
|
|
72
|
-
borderRadius: '4px',
|
|
73
|
-
}}
|
|
74
|
-
/>
|
|
75
|
-
|
|
76
|
-
// custom render function
|
|
77
|
-
<FacebookLogin
|
|
78
|
-
appId="1088597931155576"
|
|
79
|
-
onSuccess={(response) => {
|
|
80
|
-
console.log('Login Success!', response);
|
|
81
|
-
}}
|
|
82
|
-
onFail={(error) => {
|
|
83
|
-
console.log('Login Failed!', error);
|
|
84
|
-
}}
|
|
85
|
-
onProfileSuccess={(response) => {
|
|
86
|
-
console.log('Get Profile Success!', response);
|
|
87
|
-
}}
|
|
88
|
-
render={({ onClick, logout }) => (
|
|
89
|
-
<CustomComponent onClick={onClick} onLogoutClick={logout} />
|
|
90
|
-
)}
|
|
91
|
-
/>
|
|
92
|
-
|
|
93
|
-
// custom params, options
|
|
94
|
-
<FacebookLogin
|
|
95
|
-
appId="1088597931155576"
|
|
96
|
-
useRedirect
|
|
97
|
-
initParams={{
|
|
98
|
-
version: 'v10.0',
|
|
99
|
-
xfbml: true,
|
|
100
|
-
}}
|
|
101
|
-
dialogParams={{
|
|
102
|
-
response_type: 'token',
|
|
103
|
-
}}
|
|
104
|
-
loginOptions={{
|
|
105
|
-
return_scopes: true,
|
|
106
|
-
}}
|
|
107
|
-
/>
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### FacebookLoginClient
|
|
111
|
-
|
|
112
|
-
You can manually call facebook sdk related functions with FacebookLoginClient
|
|
113
|
-
|
|
114
|
-
```tsx
|
|
115
|
-
import { FacebookLoginClient } from 'react-fb-login';
|
|
116
|
-
|
|
117
|
-
FacebookLoginClient.getLoginStatus((res) => {
|
|
118
|
-
console.log(res.status);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
FacebookLoginClient.login((res) => {
|
|
122
|
-
console.log(res);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
FacebookLoginClient.getProfile((res) => {
|
|
126
|
-
console.log(res.id, res.name, res.email);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
FacebookLoginClient.logout(() => {
|
|
130
|
-
console.log('logout completed!');
|
|
131
|
-
});
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
## Examples
|
|
135
|
-
|
|
136
|
-
You can checkout examples [here](./examples)
|
|
137
|
-
|
|
138
|
-
## Props
|
|
139
|
-
|
|
140
|
-
Check all available params,options [here](./docs/params.md)
|
|
141
|
-
|
|
142
|
-
| Property | Description | Type | Default |
|
|
143
|
-
| ---------------- | ------------------------------------------------ | --------------------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
144
|
-
| appId \* | Your application ID. | string | - |
|
|
145
|
-
| language | API version | string | 'en_US' |
|
|
146
|
-
| scope | Comma seperated list of permissions for login. | string | 'public_profile, email' |
|
|
147
|
-
| fields | fields return by /me (profile) | string | 'name,email,picture' |
|
|
148
|
-
| onSuccess | | function | - |
|
|
149
|
-
| onFail | | function | - |
|
|
150
|
-
| onProfileSuccess | | function | - |
|
|
151
|
-
| style | css properties for login button | CSSProperties | - |
|
|
152
|
-
| children | Children Component | ReactNode \| ReactNodeArray | "Login with Facebook" |
|
|
153
|
-
| render | Callback which render custom component | function | - |
|
|
154
|
-
| autoLoad | if true, request login on mount | boolean | false |
|
|
155
|
-
| useRedirect | if true, use redirect instead of window.FB.login | boolean | false (forced to be true in fb browers ([ref](https://github.com/Evolve-Next/react-facebook-login/issues/2))) |
|
|
156
|
-
| useCustomChat | if true, append 'xfbml.customerchat' to sdk url | boolean | false |
|
|
157
|
-
| initParams | params for FB.init | InitParams | [docs](./docs/params.md) |
|
|
158
|
-
| dialogParams | params for login dialog | DialogParams | [docs](./docs/params.md) |
|
|
159
|
-
| loginOptions | options for FB.login | LoginOptions | [docs](./docs/params.md) |
|
|
160
|
-
|
|
161
|
-
<br/>
|
|
162
|
-
|
|
163
|
-
## Stay in touch
|
|
164
|
-
|
|
165
|
-
- Author - [Sumin Choi](https://sumini.dev)
|
|
166
|
-
|
|
167
|
-
## License
|
|
168
|
-
|
|
169
|
-
React Facebook Login is [MIT licensed](./LICENSE).
|
|
170
|
-
|
|
171
|
-
## Links
|
|
172
|
-
|
|
173
|
-
- [NPM](https://www.npmjs.com/package/react-fb-login)
|
|
174
|
-
- [GitHub](https://github.com/Evolve-Next/react-facebook-login)
|
|
175
|
-
- [(Official) Facebook Login Guide](https://developers.facebook.com/docs/facebook-login/web)
|
|
1
|
+
# React Fb Login
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/react-fb-login)
|
|
4
|
+
[](https://www.npmjs.com/package/react-fb-login)
|
|
5
|
+
[](https://www.npmjs.com/package/react-fb-login)
|
|
6
|
+
[](https://github.com/Evolve-Next/react-facebook-login/actions/workflows/ci.yml)
|
|
7
|
+
[](https://github.com/Evolve-Next/react-facebook-login/actions/workflows/cd.yml)
|
|
8
|
+
[](https://github.com/Evolve-Next/react-facebook-login)
|
|
9
|
+
|
|
10
|
+
<br/>
|
|
11
|
+
|
|
12
|
+
React Component for Facebook Login. aims to improve [react-facebook-login](https://github.com/keppelen/react-facebook-login).<br/>
|
|
13
|
+
[한글 가이드](https://sumini.dev/guide/016-react-facebook-login/)
|
|
14
|
+
|
|
15
|
+
- 💙 Typescript support
|
|
16
|
+
- 📦 6kb mini library
|
|
17
|
+
- 👫 All browsers supported
|
|
18
|
+
- 🏃 Currently maintaining
|
|
19
|
+
|
|
20
|
+
## Table of contents
|
|
21
|
+
|
|
22
|
+
- [React Fb Login](#react-fb-login)
|
|
23
|
+
- [Table of contents](#table-of-contents)
|
|
24
|
+
- [Getting Started](#getting-started)
|
|
25
|
+
- [Usage](#usage)
|
|
26
|
+
- [Component](#component)
|
|
27
|
+
- [FacebookLoginClient](#facebookloginclient)
|
|
28
|
+
- [Examples](#examples)
|
|
29
|
+
- [Props](#props)
|
|
30
|
+
- [Stay in touch](#stay-in-touch)
|
|
31
|
+
- [License](#license)
|
|
32
|
+
- [Links](#links)
|
|
33
|
+
|
|
34
|
+
## Getting Started
|
|
35
|
+
|
|
36
|
+
```shell
|
|
37
|
+
npm i --save react-fb-login
|
|
38
|
+
# or
|
|
39
|
+
yarn add react-fb-login
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
### Component
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
import FacebookLogin from 'react-fb-login';
|
|
48
|
+
|
|
49
|
+
// default
|
|
50
|
+
<FacebookLogin
|
|
51
|
+
appId="1088597931155576"
|
|
52
|
+
onSuccess={(response) => {
|
|
53
|
+
console.log('Login Success!', response);
|
|
54
|
+
}}
|
|
55
|
+
onFail={(error) => {
|
|
56
|
+
console.log('Login Failed!', error);
|
|
57
|
+
}}
|
|
58
|
+
onProfileSuccess={(response) => {
|
|
59
|
+
console.log('Get Profile Success!', response);
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
62
|
+
|
|
63
|
+
// custom style
|
|
64
|
+
<FacebookLogin
|
|
65
|
+
appId="1088597931155576"
|
|
66
|
+
style={{
|
|
67
|
+
backgroundColor: '#4267b2',
|
|
68
|
+
color: '#fff',
|
|
69
|
+
fontSize: '16px',
|
|
70
|
+
padding: '12px 24px',
|
|
71
|
+
border: 'none',
|
|
72
|
+
borderRadius: '4px',
|
|
73
|
+
}}
|
|
74
|
+
/>
|
|
75
|
+
|
|
76
|
+
// custom render function
|
|
77
|
+
<FacebookLogin
|
|
78
|
+
appId="1088597931155576"
|
|
79
|
+
onSuccess={(response) => {
|
|
80
|
+
console.log('Login Success!', response);
|
|
81
|
+
}}
|
|
82
|
+
onFail={(error) => {
|
|
83
|
+
console.log('Login Failed!', error);
|
|
84
|
+
}}
|
|
85
|
+
onProfileSuccess={(response) => {
|
|
86
|
+
console.log('Get Profile Success!', response);
|
|
87
|
+
}}
|
|
88
|
+
render={({ onClick, logout }) => (
|
|
89
|
+
<CustomComponent onClick={onClick} onLogoutClick={logout} />
|
|
90
|
+
)}
|
|
91
|
+
/>
|
|
92
|
+
|
|
93
|
+
// custom params, options
|
|
94
|
+
<FacebookLogin
|
|
95
|
+
appId="1088597931155576"
|
|
96
|
+
useRedirect
|
|
97
|
+
initParams={{
|
|
98
|
+
version: 'v10.0',
|
|
99
|
+
xfbml: true,
|
|
100
|
+
}}
|
|
101
|
+
dialogParams={{
|
|
102
|
+
response_type: 'token',
|
|
103
|
+
}}
|
|
104
|
+
loginOptions={{
|
|
105
|
+
return_scopes: true,
|
|
106
|
+
}}
|
|
107
|
+
/>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### FacebookLoginClient
|
|
111
|
+
|
|
112
|
+
You can manually call facebook sdk related functions with FacebookLoginClient
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
import { FacebookLoginClient } from 'react-fb-login';
|
|
116
|
+
|
|
117
|
+
FacebookLoginClient.getLoginStatus((res) => {
|
|
118
|
+
console.log(res.status);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
FacebookLoginClient.login((res) => {
|
|
122
|
+
console.log(res);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
FacebookLoginClient.getProfile((res) => {
|
|
126
|
+
console.log(res.id, res.name, res.email);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
FacebookLoginClient.logout(() => {
|
|
130
|
+
console.log('logout completed!');
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Examples
|
|
135
|
+
|
|
136
|
+
You can checkout examples [here](./examples)
|
|
137
|
+
|
|
138
|
+
## Props
|
|
139
|
+
|
|
140
|
+
Check all available params,options [here](./docs/params.md)
|
|
141
|
+
|
|
142
|
+
| Property | Description | Type | Default |
|
|
143
|
+
| ---------------- | ------------------------------------------------ | --------------------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
144
|
+
| appId \* | Your application ID. | string | - |
|
|
145
|
+
| language | API version | string | 'en_US' |
|
|
146
|
+
| scope | Comma seperated list of permissions for login. | string | 'public_profile, email' |
|
|
147
|
+
| fields | fields return by /me (profile) | string | 'name,email,picture' |
|
|
148
|
+
| onSuccess | | function | - |
|
|
149
|
+
| onFail | | function | - |
|
|
150
|
+
| onProfileSuccess | | function | - |
|
|
151
|
+
| style | css properties for login button | CSSProperties | - |
|
|
152
|
+
| children | Children Component | ReactNode \| ReactNodeArray | "Login with Facebook" |
|
|
153
|
+
| render | Callback which render custom component | function | - |
|
|
154
|
+
| autoLoad | if true, request login on mount | boolean | false |
|
|
155
|
+
| useRedirect | if true, use redirect instead of window.FB.login | boolean | false (forced to be true in fb browers ([ref](https://github.com/Evolve-Next/react-facebook-login/issues/2))) |
|
|
156
|
+
| useCustomChat | if true, append 'xfbml.customerchat' to sdk url | boolean | false |
|
|
157
|
+
| initParams | params for FB.init | InitParams | [docs](./docs/params.md) |
|
|
158
|
+
| dialogParams | params for login dialog | DialogParams | [docs](./docs/params.md) |
|
|
159
|
+
| loginOptions | options for FB.login | LoginOptions | [docs](./docs/params.md) |
|
|
160
|
+
|
|
161
|
+
<br/>
|
|
162
|
+
|
|
163
|
+
## Stay in touch
|
|
164
|
+
|
|
165
|
+
- Author - [Sumin Choi](https://sumini.dev)
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
React Facebook Login is [MIT licensed](./LICENSE).
|
|
170
|
+
|
|
171
|
+
## Links
|
|
172
|
+
|
|
173
|
+
- [NPM](https://www.npmjs.com/package/react-fb-login)
|
|
174
|
+
- [GitHub](https://github.com/Evolve-Next/react-facebook-login)
|
|
175
|
+
- [(Official) Facebook Login Guide](https://developers.facebook.com/docs/facebook-login/web)
|
|
@@ -69,13 +69,16 @@ export type LoginOptions = {
|
|
|
69
69
|
* @default false */
|
|
70
70
|
ignoreSdkError?: boolean;
|
|
71
71
|
extras?: {
|
|
72
|
-
version?:
|
|
72
|
+
version?: string;
|
|
73
73
|
sessionInfoVersion?: string;
|
|
74
74
|
featureType?: string;
|
|
75
|
+
feature?: string;
|
|
75
76
|
features?: {
|
|
76
77
|
name: string;
|
|
77
78
|
}[];
|
|
78
|
-
setup?:
|
|
79
|
+
setup?: {
|
|
80
|
+
solutionID: string;
|
|
81
|
+
};
|
|
79
82
|
};
|
|
80
83
|
};
|
|
81
84
|
export type FacebookLoginProps = Pick<InitParams, 'appId'> & {
|
package/examples/with-client.tsx
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { FacebookLoginClient } from '../src/facebook-login.client';
|
|
3
|
-
|
|
4
|
-
const appId = '1088597931155576';
|
|
5
|
-
|
|
6
|
-
export const Default = () => {
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
FacebookLoginClient.init({ appId });
|
|
9
|
-
}, []);
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<button
|
|
13
|
-
onClick={() => {
|
|
14
|
-
FacebookLoginClient.login(console.log, {
|
|
15
|
-
scope: 'public_profile, email',
|
|
16
|
-
});
|
|
17
|
-
}}
|
|
18
|
-
>
|
|
19
|
-
login with facebook
|
|
20
|
-
</button>
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const WithMultipleApp = () => {
|
|
25
|
-
const [app, setApp] = useState(0);
|
|
26
|
-
const appIds = ['1088597931155576', '2363450737249976'];
|
|
27
|
-
|
|
28
|
-
const toggleApp = () => setApp((prev) => 1 - prev);
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
loadFB();
|
|
32
|
-
}, [app]);
|
|
33
|
-
|
|
34
|
-
const loadFB = async () => {
|
|
35
|
-
FacebookLoginClient.clear();
|
|
36
|
-
await FacebookLoginClient.loadSdk('en_US');
|
|
37
|
-
FacebookLoginClient.init({ appId: appIds[app], version: 'v9.0' });
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<div>
|
|
42
|
-
<button onClick={toggleApp} style={{ marginBottom: '12px' }}>
|
|
43
|
-
toggle app
|
|
44
|
-
</button>
|
|
45
|
-
<button
|
|
46
|
-
onClick={() =>
|
|
47
|
-
FacebookLoginClient.login(console.log, {
|
|
48
|
-
scope: 'public_profile, email',
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
>
|
|
52
|
-
Login to APP {app}
|
|
53
|
-
</button>
|
|
54
|
-
</div>
|
|
55
|
-
);
|
|
56
|
-
};
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { FacebookLoginClient } from '../src/facebook-login.client';
|
|
3
|
+
|
|
4
|
+
const appId = '1088597931155576';
|
|
5
|
+
|
|
6
|
+
export const Default = () => {
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
FacebookLoginClient.init({ appId });
|
|
9
|
+
}, []);
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<button
|
|
13
|
+
onClick={() => {
|
|
14
|
+
FacebookLoginClient.login(console.log, {
|
|
15
|
+
scope: 'public_profile, email',
|
|
16
|
+
});
|
|
17
|
+
}}
|
|
18
|
+
>
|
|
19
|
+
login with facebook
|
|
20
|
+
</button>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const WithMultipleApp = () => {
|
|
25
|
+
const [app, setApp] = useState(0);
|
|
26
|
+
const appIds = ['1088597931155576', '2363450737249976'];
|
|
27
|
+
|
|
28
|
+
const toggleApp = () => setApp((prev) => 1 - prev);
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
loadFB();
|
|
32
|
+
}, [app]);
|
|
33
|
+
|
|
34
|
+
const loadFB = async () => {
|
|
35
|
+
FacebookLoginClient.clear();
|
|
36
|
+
await FacebookLoginClient.loadSdk('en_US');
|
|
37
|
+
FacebookLoginClient.init({ appId: appIds[app], version: 'v9.0' });
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div>
|
|
42
|
+
<button onClick={toggleApp} style={{ marginBottom: '12px' }}>
|
|
43
|
+
toggle app
|
|
44
|
+
</button>
|
|
45
|
+
<button
|
|
46
|
+
onClick={() =>
|
|
47
|
+
FacebookLoginClient.login(console.log, {
|
|
48
|
+
scope: 'public_profile, email',
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
>
|
|
52
|
+
Login to APP {app}
|
|
53
|
+
</button>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import FacebookLogin from '../src/facebook-login';
|
|
4
|
-
|
|
5
|
-
const appId = '1088597931155576';
|
|
6
|
-
|
|
7
|
-
export const Default = () => <FacebookLogin appId={appId} />;
|
|
8
|
-
|
|
9
|
-
export const WithStyle = () => (
|
|
10
|
-
<FacebookLogin
|
|
11
|
-
appId={appId}
|
|
12
|
-
initParams={{
|
|
13
|
-
version: 'v10.0',
|
|
14
|
-
}}
|
|
15
|
-
style={{
|
|
16
|
-
backgroundColor: '#4267b2',
|
|
17
|
-
color: '#fff',
|
|
18
|
-
fontSize: '16px',
|
|
19
|
-
padding: '12px 24px',
|
|
20
|
-
border: 'none',
|
|
21
|
-
borderRadius: '4px',
|
|
22
|
-
}}
|
|
23
|
-
/>
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
export const WithChildren = () => (
|
|
27
|
-
<FacebookLogin appId={appId} children={<div>Hello Facebook!</div>} />
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
export const WithRender = () => (
|
|
31
|
-
<FacebookLogin
|
|
32
|
-
appId={appId}
|
|
33
|
-
render={({ onClick }) => <a onClick={onClick}>Custom Component</a>}
|
|
34
|
-
/>
|
|
35
|
-
);
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import FacebookLogin from '../src/facebook-login';
|
|
4
|
+
|
|
5
|
+
const appId = '1088597931155576';
|
|
6
|
+
|
|
7
|
+
export const Default = () => <FacebookLogin appId={appId} />;
|
|
8
|
+
|
|
9
|
+
export const WithStyle = () => (
|
|
10
|
+
<FacebookLogin
|
|
11
|
+
appId={appId}
|
|
12
|
+
initParams={{
|
|
13
|
+
version: 'v10.0',
|
|
14
|
+
}}
|
|
15
|
+
style={{
|
|
16
|
+
backgroundColor: '#4267b2',
|
|
17
|
+
color: '#fff',
|
|
18
|
+
fontSize: '16px',
|
|
19
|
+
padding: '12px 24px',
|
|
20
|
+
border: 'none',
|
|
21
|
+
borderRadius: '4px',
|
|
22
|
+
}}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export const WithChildren = () => (
|
|
27
|
+
<FacebookLogin appId={appId} children={<div>Hello Facebook!</div>} />
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export const WithRender = () => (
|
|
31
|
+
<FacebookLogin
|
|
32
|
+
appId={appId}
|
|
33
|
+
render={({ onClick }) => <a onClick={onClick}>Custom Component</a>}
|
|
34
|
+
/>
|
|
35
|
+
);
|
package/package.json
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "react-es-fb-login",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"keywords": [
|
|
5
|
-
"react",
|
|
6
|
-
"reactjs",
|
|
7
|
-
"facebook",
|
|
8
|
-
"oauth",
|
|
9
|
-
"typescript"
|
|
10
|
-
],
|
|
11
|
-
"description": "Well-typed React Component for Facebook Login",
|
|
12
|
-
"main": "dist/index.js",
|
|
13
|
-
"scripts": {
|
|
14
|
-
"check:lint": "eslint \"src/**/*.{ts,tsx}\" --fix",
|
|
15
|
-
"check:type": "tsc --noEmit",
|
|
16
|
-
"check:test": "jest",
|
|
17
|
-
"check": "run-p check:*",
|
|
18
|
-
"test:watch": "jest --watch",
|
|
19
|
-
"coverage": "jest --coverage",
|
|
20
|
-
"build": "rimraf -rf dist && tsc -p tsconfig.json",
|
|
21
|
-
"prepublish:npm": "npm run check && npm run build",
|
|
22
|
-
"publish:npm": "npm publish --public"
|
|
23
|
-
},
|
|
24
|
-
"license": "MIT",
|
|
25
|
-
"repository": {
|
|
26
|
-
"type": "git",
|
|
27
|
-
"url": "git+https://github.com/Evolve-Next/react-facebook-login.git"
|
|
28
|
-
},
|
|
29
|
-
"bugs": {
|
|
30
|
-
"url": "https://github.com/Evolve-Next/react-facebook-login/issues"
|
|
31
|
-
},
|
|
32
|
-
"homepage": "https://github.com/Evolve-Next/react-facebook-login",
|
|
33
|
-
"peerDependencies": {
|
|
34
|
-
"react": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0"
|
|
35
|
-
},
|
|
36
|
-
"devDependencies": {
|
|
37
|
-
"@babel/core": "7.23.3",
|
|
38
|
-
"@mdx-js/react": "3.0.0",
|
|
39
|
-
"@testing-library/jest-dom": "6.1.4",
|
|
40
|
-
"@testing-library/react": "14.1.0",
|
|
41
|
-
"@types/jest": "29.5.8",
|
|
42
|
-
"@types/node": "20.9.1",
|
|
43
|
-
"@types/react": "18.0.28",
|
|
44
|
-
"@types/react-dom": "^18.0.11",
|
|
45
|
-
"@types/testing-library__jest-dom": "5.14.9",
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "5.62.0",
|
|
47
|
-
"@typescript-eslint/parser": "5.62.0",
|
|
48
|
-
"babel-loader": "9.1.3",
|
|
49
|
-
"eslint": "8.53.0",
|
|
50
|
-
"eslint-config-prettier": "9.0.0",
|
|
51
|
-
"eslint-plugin-import": "2.29.0",
|
|
52
|
-
"jest": "29.7.0",
|
|
53
|
-
"jest-environment-jsdom": "29.7.0",
|
|
54
|
-
"npm-run-all": "4.1.5",
|
|
55
|
-
"prettier": "3.1.0",
|
|
56
|
-
"react": "18.2.0",
|
|
57
|
-
"react-dom": "18.2.0",
|
|
58
|
-
"rimraf": "5.0.5",
|
|
59
|
-
"ts-jest": "29.1.1",
|
|
60
|
-
"typescript": "5.2.2"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "react-es-fb-login",
|
|
3
|
+
"version": "1.0.8",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"react",
|
|
6
|
+
"reactjs",
|
|
7
|
+
"facebook",
|
|
8
|
+
"oauth",
|
|
9
|
+
"typescript"
|
|
10
|
+
],
|
|
11
|
+
"description": "Well-typed React Component for Facebook Login",
|
|
12
|
+
"main": "dist/index.js",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"check:lint": "eslint \"src/**/*.{ts,tsx}\" --fix",
|
|
15
|
+
"check:type": "tsc --noEmit",
|
|
16
|
+
"check:test": "jest",
|
|
17
|
+
"check": "run-p check:*",
|
|
18
|
+
"test:watch": "jest --watch",
|
|
19
|
+
"coverage": "jest --coverage",
|
|
20
|
+
"build": "rimraf -rf dist && tsc -p tsconfig.json",
|
|
21
|
+
"prepublish:npm": "npm run check && npm run build",
|
|
22
|
+
"publish:npm": "npm publish --public"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/Evolve-Next/react-facebook-login.git"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/Evolve-Next/react-facebook-login/issues"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/Evolve-Next/react-facebook-login",
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"react": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@babel/core": "7.23.3",
|
|
38
|
+
"@mdx-js/react": "3.0.0",
|
|
39
|
+
"@testing-library/jest-dom": "6.1.4",
|
|
40
|
+
"@testing-library/react": "14.1.0",
|
|
41
|
+
"@types/jest": "29.5.8",
|
|
42
|
+
"@types/node": "20.9.1",
|
|
43
|
+
"@types/react": "18.0.28",
|
|
44
|
+
"@types/react-dom": "^18.0.11",
|
|
45
|
+
"@types/testing-library__jest-dom": "5.14.9",
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "5.62.0",
|
|
47
|
+
"@typescript-eslint/parser": "5.62.0",
|
|
48
|
+
"babel-loader": "9.1.3",
|
|
49
|
+
"eslint": "8.53.0",
|
|
50
|
+
"eslint-config-prettier": "9.0.0",
|
|
51
|
+
"eslint-plugin-import": "2.29.0",
|
|
52
|
+
"jest": "29.7.0",
|
|
53
|
+
"jest-environment-jsdom": "29.7.0",
|
|
54
|
+
"npm-run-all": "4.1.5",
|
|
55
|
+
"prettier": "3.1.0",
|
|
56
|
+
"react": "18.2.0",
|
|
57
|
+
"react-dom": "18.2.0",
|
|
58
|
+
"rimraf": "5.0.5",
|
|
59
|
+
"ts-jest": "29.1.1",
|
|
60
|
+
"typescript": "5.2.2"
|
|
61
|
+
}
|
|
62
|
+
}
|