@@ -174,16 +174,6 @@ function Dashboard() {
-**As a render prop**: This is also exported as a render prop component, `NetlifyIdentity`, but we're not quite sure if its that useful if you can already use hooks in your app:
-
-```tsx
-
- {({ loginUser, signupUser }) => {
- // use it
- }}
-
-```
-
## License
MIT © [sw-yx](https://github.com/sw-yx)
diff --git a/example/.gitignore b/example/.gitignore
index 4d29575..8f9b412 100644
--- a/example/.gitignore
+++ b/example/.gitignore
@@ -4,7 +4,7 @@
/node_modules
/.pnp
.pnp.js
-
+.cache
# testing
/coverage
diff --git a/example/index.html b/example/index.html
new file mode 100644
index 0000000..b54da92
--- /dev/null
+++ b/example/index.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+
Playground
+
+
+
+
+
+
+
diff --git a/example/package.json b/example/package.json
index 3ec29ca..9194535 100644
--- a/example/package.json
+++ b/example/package.json
@@ -1,41 +1,29 @@
{
"name": "example",
- "version": "0.1.0",
- "private": true,
+ "version": "1.0.0",
+ "main": "index.js",
+ "license": "MIT",
+ "scripts": {
+ "start": "parcel index.html",
+ "build": "parcel build index.html"
+ },
"dependencies": {
"@reach/router": "^1.2.1",
+ "react-app-polyfill": "^1.0.1",
"react-netlify-identity": "latest",
- "react-scripts": "3.0.0",
+ "react": "latest",
+ "react-dom": "latest",
"typescript": "3.4.5"
},
- "scripts": {
- "start": "react-scripts start",
- "build": "react-scripts build",
- "test": "react-scripts test",
- "eject": "react-scripts eject"
- },
- "eslintConfig": {
- "extends": "react-app"
- },
- "browserslist": {
- "production": [
- ">0.2%",
- "not dead",
- "not op_mini all"
- ],
- "development": [
- "last 1 chrome version",
- "last 1 firefox version",
- "last 1 safari version"
- ]
- },
"devDependencies": {
- "@types/jest": "24.0.11",
- "@types/node": "11.13.8",
"@types/reach__router": "^1.2.4",
- "@types/react": "16.8.14",
- "@types/react-dom": "16.8.4",
- "react": "^16.8.6",
- "react-dom": "^16.8.6"
- }
+ "@types/react": "^16.8.15",
+ "@types/react-dom": "^16.8.4",
+ "parcel": "^1.12.3",
+ "typescript": "^3.4.5"
+ },
+ "browserslist": [
+ "last 1 chrome version",
+ "not dead"
+ ]
}
diff --git a/example/src/App.tsx b/example/src/App.tsx
index 02b46c0..d25d295 100644
--- a/example/src/App.tsx
+++ b/example/src/App.tsx
@@ -1,14 +1,17 @@
-import React from "react"
-import { Router, Link, navigate } from "@reach/router"
-import "./App.css"
-import { useNetlifyIdentity, Settings } from "react-netlify-identity"
-import useLoading from "./useLoading"
+import React from 'react';
+import { Router, Link, navigate } from '@reach/router';
+import './App.css';
+import { useIdentityCtx, IdentityContextProvider, Settings } from '../../src';
+import useLoading from './useLoading';
-let IdentityContext = React.createContext
>(undefined!)
-type MaybePathProps = { path?: string }
-function PrivateRoute(props: React.PropsWithoutRef }>) {
- const identity = React.useContext(IdentityContext)
- let { as: Comp } = props
+type MaybePathProps = { path?: string };
+function PrivateRoute(
+ props: React.PropsWithoutRef<
+ MaybePathProps & { as: React.ComponentType }
+ >
+) {
+ const identity = useIdentityCtx();
+ let { as: Comp } = props;
return identity.user ? (
) : (
@@ -16,41 +19,47 @@ function PrivateRoute(props: React.PropsWithoutRefYou are trying to view a protected page. Please log in
- )
+ );
}
function Login({ }: MaybePathProps) {
- const { loginUser, signupUser, settings, loginProvider } = React.useContext(IdentityContext)
- const formRef = React.useRef