-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexander Iklyukov
committed
Oct 21, 2023
1 parent
4940116
commit d607b20
Showing
24 changed files
with
390 additions
and
82 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Demo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
{ | ||
"name": "@favy/wayfind-react", | ||
"license": "MIT", | ||
"version": "0.0.1", | ||
"version": "0.0.3", | ||
"main": "./src/index.ts", | ||
"module": "./src/index.ts", | ||
"exports": { | ||
".": { | ||
"import": "./src/index.ts", | ||
"require": "./src/index.ts" | ||
} | ||
}, | ||
"scripts": { | ||
"build": "tsup index.ts --format cjs,esm --dts", | ||
"build": "tsup src/index.ts --format cjs,esm --dts", | ||
"release": "pnpm run build && changeset publish", | ||
"lint": "tsc" | ||
}, | ||
"devDependencies": { | ||
"@changesets/cli": "^2.26.1", | ||
"@favy/wayfind": "workspace:*", | ||
"@types/react": "^18.2.8", | ||
"tsup": "^7.2.0", | ||
"typescript": "^5.2.2" | ||
}, | ||
"peerDependencies": { | ||
"react": "^18.2.0" | ||
"react": "^18.2.0", | ||
"@favy/wayfind": "workspace:*" | ||
}, | ||
"dependencies": { | ||
"react": "^18.2.0", | ||
"type-fest": "^4.4.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# wayfind-react |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
import { useContext, useLayoutEffect } from "react"; | ||
import { RouterContext } from "../RouterContext"; | ||
import { ToRouteProps } from "./Link"; | ||
|
||
export const Redirect = <T extends string, V>({ to, vars }: { to: T; vars: V }) => { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-expect-error | ||
export const Redirect = <T extends string, V>({ to, vars }: ToRouteProps<T, V>) => { | ||
const ctx = useContext(RouterContext).router; | ||
|
||
useLayoutEffect(() => { | ||
ctx?.go(to); | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-expect-error | ||
ctx?.go(to, vars); | ||
}); | ||
|
||
return <></>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import { useContext } from "react"; | ||
import { RouterContext } from "../RouterContext"; | ||
|
||
export const makeNavigateHook = <T extends string>() => { | ||
const useNavigate = () => { | ||
const ctx = useContext(RouterContext).router; | ||
return <U extends T>(url: U) => ctx?.go(url); | ||
} | ||
|
||
return useNavigate | ||
} | ||
export const makeNavigateHook = <P>() => { | ||
const useNavigate = () => { | ||
const ctx = useContext(RouterContext).router; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return (props: P) => ctx?.go(props.url, props.vars); | ||
}; | ||
|
||
return useNavigate; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# wayfind |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { RouteType } from "./RouteType"; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export const route = <const C extends RouteType<any, any>>(config: C) => { | ||
return config; | ||
}; |
Oops, something went wrong.