-
-
Notifications
You must be signed in to change notification settings - Fork 258
Expand file tree
/
Copy pathReactRouter.res
More file actions
118 lines (94 loc) · 3.02 KB
/
ReactRouter.res
File metadata and controls
118 lines (94 loc) · 3.02 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
type navigateOptions = {replace?: bool}
@module("react-router-dom")
external navigate: (string, ~options: navigateOptions=?) => unit = "navigate"
// https://api.reactrouter.com/v7/functions/react_router.useNavigate.html
@module("react-router")
external useNavigate: unit => string => unit = "useNavigate"
@module("react-router")
external useSearchParams: unit => (WebAPI.URLAPI.urlSearchParams, {..} => unit) = "useSearchParams"
@module("react-router")
external useLoaderData: unit => 'a = "useLoaderData"
/* The types for this are auto-generated from the react-router.config.mjs file */
type path = {pathname: Path.t, search?: string, hash?: option<string>}
module Loader = {
type loaderArgs = {request: WebAPI.FetchAPI.request}
type t<'a> = loaderArgs => promise<'a>
}
module Outlet = {
@module("react-router") @react.component
external make: unit => React.element = "Outlet"
}
module ScrollRestoration = {
@module("react-router") @react.component
external make: unit => React.element = "ScrollRestoration"
}
module Meta = {
@module("react-router") @react.component
external make: unit => React.element = "Meta"
}
module Links = {
@module("react-router") @react.component
external make: unit => React.element = "Links"
}
module Scripts = {
@module("react-router") @react.component
external make: unit => React.element = "Scripts"
}
module Link = {
type prefetch = [#none | #intent | #render | #viewport]
@module("react-router") @react.component
external make: (
~children: React.element=?,
~className: string=?,
~target: string=?,
~to: Path.t,
~preventScrollReset: bool=?,
~prefetch: prefetch=?,
) => React.element = "Link"
module Path = {
type to = {hash?: string, pathname?: Path.t, search?: string}
@module("react-router") @react.component
external make: (
~onClick: ReactEvent.Mouse.t => unit=?,
~children: React.element=?,
~className: string=?,
~target: string=?,
~id: string=?,
~to: to,
~preventScrollReset: bool=?,
~prefetch: prefetch=?,
) => React.element = "Link"
}
module String = {
@module("react-router") @react.component
external make: (
~title: string=?,
~onClick: ReactEvent.Mouse.t => unit=?,
~children: React.element=?,
~className: string=?,
~target: string=?,
~to: string,
~preventScrollReset: bool=?,
~relative: string=?,
~prefetch: prefetch=?,
) => React.element = "Link"
}
}
@module("react-router")
external useLocation: unit => path = "useLocation"
module Routes = {
type t = {
id: string,
path?: string,
}
type config = array<t>
@module("@react-router/dev/routes")
external index: string => t = "index"
type routeOptions = {id?: string}
@module("@react-router/dev/routes")
external route: (string, string, ~options: routeOptions=?) => t = "route"
@module("@react-router/dev/routes")
external layout: (string, array<t>) => t = "layout"
@module("react-router-mdx/server")
external mdxRoutes: string => array<t> = "routes"
}