-
-
Notifications
You must be signed in to change notification settings - Fork 108
/
Copy pathrouter.d.ts
42 lines (34 loc) · 970 Bytes
/
router.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { AnyComponent, FunctionComponent, VNode } from 'preact';
export const LocationProvider: FunctionComponent;
export function Router(props: {
onRouteChange?: (url: string) => void;
onLoadEnd?: (url: string) => void;
onLoadStart?: (url: string) => void;
children?: VNode[];
}): VNode;
interface LocationHook {
url: string;
path: string;
query: Record<string, string>;
route: (url: string) => void;
}
export const useLocation: () => LocationHook;
export const useRoute: () => {
path: string;
query: Record<string, string>;
params: Record<string, string>;
};
interface RoutableProps {
path?: string;
default?: boolean;
}
export interface RouteProps<Props> extends RoutableProps {
component: AnyComponent<Props>;
}
export function Route<Props>(props: RouteProps<Props> & Partial<Props>): VNode;
declare module 'preact' {
namespace JSX {
interface IntrinsicAttributes extends RoutableProps {}
}
interface Attributes extends RoutableProps {}
}