1
- [ react-router-infer - v0.1 .0] ( README.md ) / Exports
1
+ [ react-router-infer - v0.2 .0] ( README.md ) / Exports
2
2
3
- # react-router-infer - v0.1 .0
3
+ # react-router-infer - v0.2 .0
4
4
5
5
## Table of contents
6
6
12
12
### Functions
13
13
14
14
- [ Link] ( modules.md#link )
15
+ - [ NavLink] ( modules.md#navlink )
16
+ - [ create\_ generatePath] ( modules.md#create_generatepath )
17
+ - [ generatePath] ( modules.md#generatepath )
15
18
- [ r] ( modules.md#r )
16
19
- [ useNavigate] ( modules.md#usenavigate )
17
20
- [ useParams] ( modules.md#useparams )
@@ -44,7 +47,7 @@ const routes = [...] as const satisfies RouteObject[]
44
47
45
48
#### Defined in
46
49
47
- [ core.ts:14] ( https://github.com/haivuw/react-router-infer/blob/449bf32 /src/core.ts#L14 )
50
+ [ core.ts:14] ( https://github.com/haivuw/react-router-infer/blob/eaa6d1d /src/core.ts#L14 )
48
51
49
52
___
50
53
@@ -56,7 +59,7 @@ Extends `react-router-dom`'s `RouteObject` with `parseSearch` fields
56
59
57
60
#### Defined in
58
61
59
- [ core.ts:35] ( https://github.com/haivuw/react-router-infer/blob/449bf32 /src/core.ts#L35 )
62
+ [ core.ts:35] ( https://github.com/haivuw/react-router-infer/blob/eaa6d1d /src/core.ts#L35 )
60
63
61
64
## Functions
62
65
@@ -97,7 +100,119 @@ const render = (
97
100
98
101
#### Defined in
99
102
100
- [ Link.tsx:24] ( https://github.com/haivuw/react-router-infer/blob/449bf32/src/Link.tsx#L24 )
103
+ [ Link.tsx:24] ( https://github.com/haivuw/react-router-infer/blob/eaa6d1d/src/Link.tsx#L24 )
104
+
105
+ ___
106
+
107
+ ### NavLink
108
+
109
+ ▸ ** NavLink** \< ` To ` \> (` props ` ): ` Element `
110
+
111
+ #### Type parameters
112
+
113
+ | Name | Type |
114
+ | :------ | :------ |
115
+ | ` To ` | extends ` string ` |
116
+
117
+ #### Parameters
118
+
119
+ | Name | Type | Description |
120
+ | :------ | :------ | :------ |
121
+ | ` props ` | ` Object ` | T |
122
+
123
+ #### Returns
124
+
125
+ ` Element `
126
+
127
+ ** ` Example ` **
128
+
129
+ ``` ts
130
+ const render = (
131
+ < NavLink
132
+ to = ' /:id'
133
+ params = {{ id : 1 }}
134
+ search = {{ page : 1 }}
135
+ // react-router's NavigateOptions
136
+ replace
137
+ {... rest }
138
+ / >
139
+ )
140
+ ```
141
+
142
+ #### Defined in
143
+
144
+ [ NavLink.tsx:22] ( https://github.com/haivuw/react-router-infer/blob/eaa6d1d/src/NavLink.tsx#L22 )
145
+
146
+ ___
147
+
148
+ ### create\_ generatePath
149
+
150
+ ▸ ** create_generatePath** (` opts? ` ): ` GeneratePath `
151
+
152
+ Return a new ` generatePath ` function that uses the custom ` stringifySearch `
153
+
154
+ #### Parameters
155
+
156
+ | Name | Type |
157
+ | :------ | :------ |
158
+ | ` opts? ` | ` Pick ` \< ` ParserUtils ` , `` "stringifySearch" `` \> |
159
+
160
+ #### Returns
161
+
162
+ ` GeneratePath `
163
+
164
+ ** ` Example ` **
165
+
166
+ ``` ts
167
+ const generatePath = create_generatePath ({
168
+ stringifySearch : () => ' ?custom' ,
169
+ })
170
+ ```
171
+
172
+ #### Defined in
173
+
174
+ [ generatePath.ts:26] ( https://github.com/haivuw/react-router-infer/blob/eaa6d1d/src/generatePath.ts#L26 )
175
+
176
+ ___
177
+
178
+ ### generatePath
179
+
180
+ ▸ ** generatePath** \< ` Routes ` , ` To ` \> (` to ` ): ` string `
181
+
182
+ #### Type parameters
183
+
184
+ | Name | Type |
185
+ | :------ | :------ |
186
+ | ` Routes ` | extends ` BaseRoutes ` = ` BaseRoutes ` |
187
+ | ` To ` | extends ` string ` \| ` number ` \| ` symbol ` = keyof ` Routes ` |
188
+
189
+ #### Parameters
190
+
191
+ | Name | Type |
192
+ | :------ | :------ |
193
+ | ` to ` | ` NavigateTo ` \< ` Routes ` , ` To ` \> |
194
+
195
+ #### Returns
196
+
197
+ ` string `
198
+
199
+ ** ` Example ` **
200
+
201
+ ``` ts
202
+ import { redirect } from ' react-router-dom'
203
+ import { generatePath } from ' react-router-infer'
204
+
205
+ const path = generatePath ({
206
+ to: ' /:id' ,
207
+ params: { id: ' 1' },
208
+ search: { page: 1 },
209
+ })
210
+ redirect (path )
211
+ ```
212
+
213
+ #### Defined in
214
+
215
+ [ generatePath.ts:54] ( https://github.com/haivuw/react-router-infer/blob/eaa6d1d/src/generatePath.ts#L54 )
101
216
102
217
___
103
218
@@ -137,23 +252,17 @@ const singleRoute = r({ path: '/' })
137
252
138
253
#### Defined in
139
254
140
- [ core.ts:142] ( https://github.com/haivuw/react-router-infer/blob/449bf32 /src/core.ts#L142 )
255
+ [ core.ts:142] ( https://github.com/haivuw/react-router-infer/blob/eaa6d1d /src/core.ts#L142 )
141
256
142
257
___
143
258
144
259
### useNavigate
145
260
146
- ▸ ** useNavigate** \< ` Routes ` \> (): ` NavigateFunction ` \< ` Routes ` \>
147
-
148
- #### Type parameters
149
-
150
- | Name | Type |
151
- | :------ | :------ |
152
- | ` Routes ` | extends ` BaseRoutes ` = ` BaseRoutes ` |
261
+ ▸ ** useNavigate** (): ` NavigateFunction ` \< ` BaseRoutes ` \>
153
262
154
263
#### Returns
155
264
156
- ` NavigateFunction ` \< ` Routes ` \>
265
+ ` NavigateFunction ` \< ` BaseRoutes ` \>
157
266
158
267
** ` Example ` **
159
268
@@ -172,20 +281,19 @@ const navigate = useNavigate()
172
281
173
282
#### Defined in
174
283
175
- [ useNavigate.ts:20] ( https://github.com/haivuw/react-router-infer/blob/449bf32 /src/useNavigate.ts#L20 )
284
+ [ useNavigate.ts:20] ( https://github.com/haivuw/react-router-infer/blob/eaa6d1d /src/useNavigate.ts#L20 )
176
285
177
286
___
178
287
179
288
### useParams
180
289
181
- ▸ ** useParams** \< ` Routes ` , ` From ` \> (` _opts? ` ): ` IsUnion ` \< ` From ` \> extends `` true `` ? ` Partial ` \< ` GetAllParams ` \< ` Routes ` , `` "params" `` \>\> : ` Partial ` \< ` ToObject ` \< ` Routes ` [ ` From ` ] [ ``"params"`` ] \> \>
290
+ ▸ ** useParams** \< ` From ` \> (` _opts? ` ): ` IsUnion ` \< ` From ` \> extends `` true `` ? ` Partial ` \< ` ParsedParams ` \> : ` Partial ` \< ` ParsedParams ` \>
182
291
183
292
#### Type parameters
184
293
185
294
| Name | Type |
186
295
| :------ | :------ |
187
- | ` Routes ` | extends ` BaseRoutes ` = ` BaseRoutes ` |
188
- | ` From ` | extends ` string ` = ` string ` & keyof ` Routes ` |
296
+ | ` From ` | extends ` string ` = ` string ` |
189
297
190
298
#### Parameters
191
299
195
303
196
304
#### Returns
197
305
198
- ` IsUnion ` \< ` From ` \> extends `` true `` ? ` Partial ` \< ` GetAllParams ` \< ` Routes ` , `` "params" `` \>\> : ` Partial ` \< ` ToObject ` \< ` Routes ` [ ` From ` ] [ ``"params"`` ] \> \>
306
+ ` IsUnion ` \< ` From ` \> extends `` true `` ? ` Partial ` \< ` ParsedParams ` \> : ` Partial ` \< ` ParsedParams ` \>
199
307
200
308
** ` Example ` **
201
309
@@ -209,20 +317,19 @@ const { id } = useParams({
209
317
210
318
#### Defined in
211
319
212
- [ useParams.ts:14] ( https://github.com/haivuw/react-router-infer/blob/449bf32 /src/useParams.ts#L14 )
320
+ [ useParams.ts:14] ( https://github.com/haivuw/react-router-infer/blob/eaa6d1d /src/useParams.ts#L14 )
213
321
214
322
___
215
323
216
324
### useSearch
217
325
218
- ▸ ** useSearch** \< ` Routes ` , ` From ` , ` Throw ` \> (` opts ` ): ` UseSearchOutput ` \< ` Routes ` , ` From ` , ` Throw ` , ` ToObject ` \< ` Routes ` [ ` From ` ] [ ``"search"`` ] \> , \{ ` isInvalidRoute ` : `` false `` ; ` search ` : ` ToObject ` \< ` Routes ` [ ` From ` ] [ ``"search"`` ] \> ; ` setSearch ` : (` search ` : ` ToObject ` \< ` Routes ` [ ` From ` ] [ ``"search"`` ] \> , ` opts? ` : ` NavigateOptions ` ) => ` void ` }, \{ ` isInvalidRoute ` : `` true `` ; ` search ` : ` undefined ` ; ` setSearch ` : ` undefined ` }\>
326
+ ▸ ** useSearch** \< ` From ` , ` Throw ` \> (` opts ` ): ` UseSearchOutput ` \< ` BaseRoutes ` , ` From ` , ` Throw ` , ` ParsedSearch ` , \{ ` isInvalidRoute ` : `` false `` ; ` search ` : ` ParsedSearch ` ; ` setSearch ` : (` search ` : ` ParsedSearch ` , ` opts? ` : ` NavigateOptions ` ) => ` void ` }, \{ ` isInvalidRoute ` : `` true `` ; ` search ` : ` undefined ` ; ` setSearch ` : ` undefined ` }\>
219
327
220
328
#### Type parameters
221
329
222
330
| Name | Type |
223
331
| :------ | :------ |
224
- | ` Routes ` | extends ` BaseRoutes ` = ` BaseRoutes ` |
225
- | ` From ` | extends ` string ` = ` string ` & keyof ` Routes ` |
332
+ | ` From ` | extends ` string ` = ` string ` |
226
333
| ` Throw ` | extends ` boolean ` = `` true `` |
227
334
228
335
#### Parameters
233
340
234
341
#### Returns
235
342
236
- ` UseSearchOutput ` \< ` Routes ` , ` From ` , ` Throw ` , ` ToObject ` \< ` Routes ` [ ` From ` ] [ ``"search"`` ] \> , \{ ` isInvalidRoute ` : `` false `` ; ` search ` : ` ToObject ` \< ` Routes ` [ ` From ` ] [ ``"search"`` ] \> ; ` setSearch ` : (` search ` : ` ToObject ` \< ` Routes ` [ ` From ` ] [ ``"search"`` ] \> , ` opts? ` : ` NavigateOptions ` ) => ` void ` }, \{ ` isInvalidRoute ` : `` true `` ; ` search ` : ` undefined ` ; ` setSearch ` : ` undefined ` }\>
343
+ ` UseSearchOutput ` \< ` BaseRoutes ` , ` From ` , ` Throw ` , ` ParsedSearch ` , \{ ` isInvalidRoute ` : `` false `` ; ` search ` : ` ParsedSearch ` ; ` setSearch ` : (` search ` : ` ParsedSearch ` , ` opts? ` : ` NavigateOptions ` ) => ` void ` }, \{ ` isInvalidRoute ` : `` true `` ; ` search ` : ` undefined ` ; ` setSearch ` : ` undefined ` }\>
237
344
238
345
** ` Example ` **
239
346
@@ -262,7 +369,7 @@ const { search, setSearch, isInvalidRoute } = useSearch({
262
369
263
370
#### Defined in
264
371
265
- [ useSearch.ts:31] ( https://github.com/haivuw/react-router-infer/blob/449bf32 /src/useSearch.ts#L31 )
372
+ [ useSearch.ts:31] ( https://github.com/haivuw/react-router-infer/blob/eaa6d1d /src/useSearch.ts#L31 )
266
373
267
374
___
268
375
@@ -301,4 +408,4 @@ Wraps user defined routes with SearchParamsProvider
301
408
302
409
#### Defined in
303
410
304
- [ SearchContext.tsx:98 ] ( https://github.com/haivuw/react-router-infer/blob/449bf32 /src/SearchContext.tsx#L98 )
411
+ [ SearchContext.tsx:94 ] ( https://github.com/haivuw/react-router-infer/blob/eaa6d1d /src/SearchContext.tsx#L94 )
0 commit comments