preact-hashish-router 0.0.12 → 0.0.13

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/README.md CHANGED
@@ -88,6 +88,26 @@ export default function Header() {
88
88
  }
89
89
  ```
90
90
 
91
+ ### `<Redirect />` Component
92
+
93
+ ```tsx
94
+ import { Redirect } from "preact-hashish-router";
95
+
96
+ export default function ProductPage() {
97
+ return (
98
+ <>
99
+ <header>
100
+ <nav>
101
+ <A href="/">Home</A>
102
+ <A href="/about">About</A>
103
+ </nav>
104
+ </header>
105
+ <Redirect to="/" />
106
+ </>
107
+ );
108
+ }
109
+ ```
110
+
91
111
  ## Development
92
112
 
93
113
  If you have any improvements or find any issues, feel free to contribute or open an issue in the associated repository.
@@ -0,0 +1,4 @@
1
+ export type RedirectProps = {
2
+ to: string;
3
+ };
4
+ export declare const Redirect: (props: RedirectProps) => import("preact").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "preact/jsx-runtime";
2
+ import { Fragment, useLayoutEffect } from "preact/compat";
3
+ import { useRouter } from "./useRouter";
4
+ export const Redirect = (props) => {
5
+ const router = useRouter();
6
+ useLayoutEffect(() => {
7
+ router.go(props.to);
8
+ }, []);
9
+ return _jsx(Fragment, {});
10
+ };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./A";
2
2
  export * from "./ErrorRoute";
3
+ export * from "./Redirect";
3
4
  export * from "./Route";
4
5
  export * from "./Router";
5
6
  export * from "./RouterErrorBoundary";
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./A";
2
2
  export * from "./ErrorRoute";
3
+ export * from "./Redirect";
3
4
  export * from "./Route";
4
5
  export * from "./Router";
5
6
  export * from "./RouterErrorBoundary";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "preact-hashish-router",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "description": "A simple router for preact",