router-hook
Advanced tools
Comparing version 3.0.6 to 4.0.0
@@ -14,3 +14,3 @@ "use strict"; | ||
const Provider_1 = __importStar(require("./Provider")); | ||
exports.Provider = Provider_1.default; | ||
exports.RouterProvider = Provider_1.default; | ||
exports.useLocation = Provider_1.useLocation; | ||
@@ -22,3 +22,5 @@ exports.useSetRoute = Provider_1.useSetRoute; | ||
exports.route = route_1.default; | ||
const A_1 = __importDefault(require("./A")); | ||
exports.A = A_1.default; | ||
const useRouter_1 = __importDefault(require("./useRouter")); | ||
exports.useRouter = useRouter_1.default; |
{ | ||
"name": "router-hook", | ||
"author": "Tim Field <tim@mohiohio.com>", | ||
"version": "3.0.6", | ||
"version": "4.0.0", | ||
"main": "dist/index.js", | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"react": "^16.8" | ||
"react": "^16" | ||
}, | ||
@@ -16,8 +16,7 @@ "dependencies": { | ||
"@types/history": "^4.7.2", | ||
"@types/path-to-regexp": "^1.7.0", | ||
"@types/react": "^16.8.19", | ||
"@types/react-dom": "^16.8.4", | ||
"@typescript-eslint/eslint-plugin": "^1.13.0", | ||
"@typescript-eslint/parser": "^1.13.0", | ||
"eslint": "^5.16.0", | ||
"@types/react": "^16", | ||
"@types/react-dom": "^16", | ||
"@typescript-eslint/eslint-plugin": "^2.29.0", | ||
"@typescript-eslint/parser": "^2.29.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-prettier": "^6.0.0", | ||
@@ -28,6 +27,6 @@ "eslint-plugin-prettier": "^3.1.0", | ||
"prettier": "^1.18.2", | ||
"react": "^16.8", | ||
"react-dom": "^16.8", | ||
"react": "^16", | ||
"react-dom": "^16", | ||
"tslib": "^1.9.3", | ||
"typescript": "^3.5.1", | ||
"typescript": "^3", | ||
"yalc": "^1.0.0-pre.27" | ||
@@ -34,0 +33,0 @@ }, |
@@ -1,2 +0,16 @@ | ||
```JS | ||
```js | ||
// index.js | ||
import { RouterProvider } from "router-hook" | ||
ReactDOM.render( | ||
<RouterProvider> | ||
<App /> | ||
</RouterProvider> | ||
document.getElementById("root") | ||
) | ||
``` | ||
```js | ||
// routes.js | ||
@@ -10,9 +24,7 @@ import { route } from "router-hook" | ||
export const editRoute = route("/thing/edit/:id?") | ||
``` | ||
```JS | ||
```jsx | ||
// Router.js | ||
import { useLocation, useSetRoute } from "router-hook" | ||
import { useLocation, useSetRoute, A } from "router-hook" | ||
import { | ||
@@ -32,3 +44,2 @@ homeRoute, | ||
const auth = render => { | ||
@@ -44,4 +55,7 @@ if (user && user.id) { | ||
return ( | ||
<Default> | ||
return ( | ||
<> | ||
<A className="App-link" href={loginRoute.toUrl()}> | ||
Login | ||
</A> | ||
{homeRoute.match(path, () => ( | ||
@@ -56,7 +70,13 @@ <Home /> | ||
))} | ||
{accountRoute.match(path, auth(() => <Account />))} | ||
{editRoute.match(path, auth(({ id }) => <Edit id={id} />))} | ||
</Default> | ||
{accountRoute.match( | ||
path, | ||
auth(() => <Account />) | ||
)} | ||
{editRoute.match( | ||
path, | ||
auth(({ id }) => <Edit id={id} />) | ||
)} | ||
</> | ||
) | ||
} | ||
``` |
@@ -1,2 +0,2 @@ | ||
import Provider, { | ||
import RouterProvider, { | ||
useLocation, | ||
@@ -8,6 +8,7 @@ useSetRoute, | ||
import route from "./route" | ||
import A from "./A" | ||
import useRouter from "./useRouter" | ||
export { | ||
Provider, | ||
RouterProvider, | ||
useLocation, | ||
@@ -18,3 +19,4 @@ useSetRoute, | ||
useRouter, | ||
useHistory | ||
useHistory, | ||
A | ||
} |
@@ -51,3 +51,3 @@ import { useEffect, useState, useCallback } from "react" | ||
useEffect(() => { | ||
window.onpopstate = function historyChange(ev) { | ||
window.onpopstate = function historyChange(ev: PopStateEvent) { | ||
if (ev.type === "popstate") { | ||
@@ -54,0 +54,0 @@ setRoute() |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16
79
8504
11
187