Skip to content

Commit c4aec46

Browse files
author
sw-yx
committed
remove boundary
1 parent cccf2fe commit c4aec46

File tree

6 files changed

+1240
-197
lines changed

6 files changed

+1240
-197
lines changed

README.md

+1-18
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,7 @@ function AuthStatusView() {
5959
}
6060
```
6161

62-
You may also code split the Modal if you wish with `React.lazy` and `React.Suspense`:
63-
64-
```js
65-
// code split the modal til you need it!
66-
const IdentityModal = React.lazy(() => import('react-netlify-identity-widget'))
67-
68-
function AuthStatusView() {
69-
// ...
70-
return (
71-
<div className="App">
72-
{/** ... */}
73-
<React.Suspense fallback="loading...">
74-
<IdentityModal showDialog={dialog} onCloseDialog={() => setDialog(false)} />
75-
</React.Suspense>
76-
</div>
77-
)
78-
}
79-
```
62+
You may also code split the Modal if you wish with `React.lazy` and `React.Suspense`.
8063

8164
## Blogposts
8265

example/package.json

+8-5
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@
66
"@reach/dialog": "^0.2.3",
77
"@reach/tabs": "^0.1.3",
88
"@reach/visually-hidden": "^0.1.3",
9+
"react": "^16.8.6",
10+
"react-dom": "^16.8.6",
11+
"react-netlify-identity": "^0.1.9",
12+
"react-netlify-identity-widget": "^0.2.1",
13+
"react-scripts": "^3.0.0"
14+
},
15+
"devDependencies": {
916
"@types/jest": "24.0.11",
1017
"@types/node": "11.13.8",
1118
"@types/react": "16.8.14",
1219
"@types/react-dom": "16.8.4",
13-
"react": "^16.8.6",
14-
"react-dom": "^16.8.6",
15-
"react-netlify-identity-widget": "^0.1.2",
16-
"react-scripts": "^3.0.0",
1720
"typescript": "3.4.5"
1821
},
1922
"scripts": {
20-
"start": "react-scripts start",
23+
"start": "REACT_APP_NETLIFY_IDENTITY_URL=https://react-netlify-identity-widget.netlify.com/ react-scripts start",
2124
"build": "react-scripts build",
2225
"test": "react-scripts test",
2326
"eject": "react-scripts eject"

example/src/App.tsx

+24-16
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,65 @@
1-
import React from "react"
2-
import "./App.css"
3-
import { useIdentityContext, IdentityContextProvider } from "react-netlify-identity-widget"
4-
import "react-netlify-identity-widget/styles.css"
1+
import React from 'react'
2+
import './App.css'
3+
import { IdentityModal, useIdentityContext, IdentityContextProvider } from 'react-netlify-identity-widget'
4+
import 'react-netlify-identity-widget/styles.css'
55

66
function App() {
77
const url = process.env.REACT_APP_NETLIFY_IDENTITY_URL // should look something like "https://foo.netlify.com"
8-
if (!url) throw new Error('process.env.REACT_APP_NETLIFY_IDENTITY_URL is blank, which means you probably forgot to set it in your Netlify environment variables')
8+
if (!url)
9+
throw new Error(
10+
'process.env.REACT_APP_NETLIFY_IDENTITY_URL is blank, which means you probably forgot to set it in your Netlify environment variables',
11+
)
912
return (
1013
<IdentityContextProvider url={url}>
1114
<AuthStatusView />
1215
</IdentityContextProvider>
1316
)
1417
}
1518

16-
// code split the modal til you need it!
17-
const IdentityModal = React.lazy(() => import("react-netlify-identity-widget"))
19+
// // code split the modal til you need it!
20+
// const IdentityModal = React.lazy(() => import('react-netlify-identity-widget'))
1821

1922
function AuthStatusView() {
2023
const identity = useIdentityContext()
2124
const [dialog, setDialog] = React.useState(false)
2225
const name =
23-
(identity && identity.user && identity.user.user_metadata && identity.user.user_metadata.full_name) || "NoName"
26+
(identity && identity.user && identity.user.user_metadata && identity.user.user_metadata.full_name) || 'NoName'
2427
const avatar_url = identity && identity.user && identity.user.user_metadata && identity.user.user_metadata.avatar_url
2528
return (
2629
<div className="App">
2730
<header className="App-header">
2831
{identity && identity.isLoggedIn ? (
2932
<>
3033
<h1> hello {name}!</h1>
31-
{avatar_url && <img alt="user name" src={avatar_url} style={{ height: 100, borderRadius: "50%" }} />}
32-
<button className="btn" style={{ maxWidth: 400, background: "orangered" }} onClick={() => setDialog(true)}>
34+
{avatar_url && <img alt="user name" src={avatar_url} style={{ height: 100, borderRadius: '50%' }} />}
35+
<button className="btn" style={{ maxWidth: 400, background: 'orangered' }} onClick={() => setDialog(true)}>
3336
LOG OUT
3437
</button>
3538
</>
3639
) : (
3740
<>
3841
<h1> hello! try logging in! </h1>
39-
<button className="btn" style={{ maxWidth: 400, background: "darkgreen" }} onClick={() => setDialog(true)}>
42+
<button className="btn" style={{ maxWidth: 400, background: 'darkgreen' }} onClick={() => setDialog(true)}>
4043
LOG IN
4144
</button>
4245
</>
4346
)}
4447

45-
<React.Suspense fallback="loading...">
46-
<IdentityModal showDialog={dialog} onCloseDialog={() => setDialog(false)} />
47-
</React.Suspense>
48+
<IdentityModal
49+
showDialog={dialog}
50+
onCloseDialog={() => setDialog(false)}
51+
onLogin={(user) => console.log('hello ', user!.user_metadata)}
52+
onSignup={(user) => console.log('welcome ', user!.user_metadata)}
53+
onLogout={() => console.log('bye ', name)}
54+
/>
55+
4856
<h3>
49-
Or{" "}
57+
Or{' '}
5058
<a
5159
href="https://github.com/sw-yx/react-netlify-identity-widget"
5260
target="_blank"
5361
rel="noopener noreferrer"
54-
style={{ color: "powderblue" }}
62+
style={{ color: 'powderblue' }}
5563
>
5664
view the source
5765
</a>

0 commit comments

Comments
 (0)