@tanstack/react-router 0.0.1-beta.177 → 0.0.1-beta.178

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.
@@ -11,19 +11,19 @@
11
11
  "children": [
12
12
  {
13
13
  "name": "@tanstack+store@0.0.1/node_modules/@tanstack/store/build/esm/index.js",
14
- "uid": "b0e2-159"
14
+ "uid": "4cc2-159"
15
15
  },
16
16
  {
17
17
  "name": "@tanstack+react-store@0.0.1/node_modules/@tanstack/react-store/build/esm/index.js",
18
- "uid": "b0e2-161"
18
+ "uid": "4cc2-161"
19
19
  },
20
20
  {
21
21
  "name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
22
- "uid": "b0e2-163"
22
+ "uid": "4cc2-163"
23
23
  },
24
24
  {
25
25
  "name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
26
- "uid": "b0e2-165"
26
+ "uid": "4cc2-165"
27
27
  }
28
28
  ]
29
29
  },
@@ -32,25 +32,25 @@
32
32
  "children": [
33
33
  {
34
34
  "name": "router-core/build/esm/index.js",
35
- "uid": "b0e2-167"
35
+ "uid": "4cc2-167"
36
36
  },
37
37
  {
38
38
  "name": "react-router/src",
39
39
  "children": [
40
40
  {
41
- "uid": "b0e2-171",
41
+ "uid": "4cc2-171",
42
42
  "name": "react.tsx"
43
43
  },
44
44
  {
45
- "uid": "b0e2-173",
45
+ "uid": "4cc2-173",
46
46
  "name": "scroll-restoration.tsx"
47
47
  },
48
48
  {
49
- "uid": "b0e2-175",
49
+ "uid": "4cc2-175",
50
50
  "name": "awaited.tsx"
51
51
  },
52
52
  {
53
- "uid": "b0e2-177",
53
+ "uid": "4cc2-177",
54
54
  "name": "index.tsx"
55
55
  }
56
56
  ]
@@ -58,7 +58,7 @@
58
58
  ]
59
59
  },
60
60
  {
61
- "uid": "b0e2-169",
61
+ "uid": "4cc2-169",
62
62
  "name": "\u0000rollupPluginBabelHelpers.js"
63
63
  }
64
64
  ]
@@ -67,302 +67,302 @@
67
67
  "isRoot": true
68
68
  },
69
69
  "nodeParts": {
70
- "b0e2-159": {
70
+ "4cc2-159": {
71
71
  "renderedLength": 1843,
72
72
  "gzipLength": 644,
73
73
  "brotliLength": 0,
74
- "mainUid": "b0e2-158"
74
+ "mainUid": "4cc2-158"
75
75
  },
76
- "b0e2-161": {
76
+ "4cc2-161": {
77
77
  "renderedLength": 1006,
78
78
  "gzipLength": 479,
79
79
  "brotliLength": 0,
80
- "mainUid": "b0e2-160"
80
+ "mainUid": "4cc2-160"
81
81
  },
82
- "b0e2-163": {
82
+ "4cc2-163": {
83
83
  "renderedLength": 181,
84
84
  "gzipLength": 129,
85
85
  "brotliLength": 0,
86
- "mainUid": "b0e2-162"
86
+ "mainUid": "4cc2-162"
87
87
  },
88
- "b0e2-165": {
88
+ "4cc2-165": {
89
89
  "renderedLength": 44,
90
90
  "gzipLength": 62,
91
91
  "brotliLength": 0,
92
- "mainUid": "b0e2-164"
92
+ "mainUid": "4cc2-164"
93
93
  },
94
- "b0e2-167": {
95
- "renderedLength": 64311,
96
- "gzipLength": 15205,
94
+ "4cc2-167": {
95
+ "renderedLength": 64128,
96
+ "gzipLength": 15188,
97
97
  "brotliLength": 0,
98
- "mainUid": "b0e2-166"
98
+ "mainUid": "4cc2-166"
99
99
  },
100
- "b0e2-169": {
100
+ "4cc2-169": {
101
101
  "renderedLength": 429,
102
102
  "gzipLength": 238,
103
103
  "brotliLength": 0,
104
- "mainUid": "b0e2-168"
104
+ "mainUid": "4cc2-168"
105
105
  },
106
- "b0e2-171": {
107
- "renderedLength": 17226,
108
- "gzipLength": 3829,
106
+ "4cc2-171": {
107
+ "renderedLength": 17344,
108
+ "gzipLength": 3846,
109
109
  "brotliLength": 0,
110
- "mainUid": "b0e2-170"
110
+ "mainUid": "4cc2-170"
111
111
  },
112
- "b0e2-173": {
112
+ "4cc2-173": {
113
113
  "renderedLength": 466,
114
114
  "gzipLength": 228,
115
115
  "brotliLength": 0,
116
- "mainUid": "b0e2-172"
116
+ "mainUid": "4cc2-172"
117
117
  },
118
- "b0e2-175": {
118
+ "4cc2-175": {
119
119
  "renderedLength": 641,
120
120
  "gzipLength": 305,
121
121
  "brotliLength": 0,
122
- "mainUid": "b0e2-174"
122
+ "mainUid": "4cc2-174"
123
123
  },
124
- "b0e2-177": {
124
+ "4cc2-177": {
125
125
  "renderedLength": 0,
126
126
  "gzipLength": 0,
127
127
  "brotliLength": 0,
128
- "mainUid": "b0e2-176"
128
+ "mainUid": "4cc2-176"
129
129
  }
130
130
  },
131
131
  "nodeMetas": {
132
- "b0e2-158": {
132
+ "4cc2-158": {
133
133
  "id": "/node_modules/.pnpm/@tanstack+store@0.0.1/node_modules/@tanstack/store/build/esm/index.js",
134
134
  "moduleParts": {
135
- "index.production.js": "b0e2-159"
135
+ "index.production.js": "4cc2-159"
136
136
  },
137
137
  "imported": [],
138
138
  "importedBy": [
139
139
  {
140
- "uid": "b0e2-160"
140
+ "uid": "4cc2-160"
141
141
  },
142
142
  {
143
- "uid": "b0e2-166"
143
+ "uid": "4cc2-166"
144
144
  }
145
145
  ]
146
146
  },
147
- "b0e2-160": {
147
+ "4cc2-160": {
148
148
  "id": "/node_modules/.pnpm/@tanstack+react-store@0.0.1/node_modules/@tanstack/react-store/build/esm/index.js",
149
149
  "moduleParts": {
150
- "index.production.js": "b0e2-161"
150
+ "index.production.js": "4cc2-161"
151
151
  },
152
152
  "imported": [
153
153
  {
154
- "uid": "b0e2-178"
154
+ "uid": "4cc2-178"
155
155
  },
156
156
  {
157
- "uid": "b0e2-158"
157
+ "uid": "4cc2-158"
158
158
  }
159
159
  ],
160
160
  "importedBy": [
161
161
  {
162
- "uid": "b0e2-176"
162
+ "uid": "4cc2-176"
163
163
  },
164
164
  {
165
- "uid": "b0e2-170"
165
+ "uid": "4cc2-170"
166
166
  }
167
167
  ]
168
168
  },
169
- "b0e2-162": {
169
+ "4cc2-162": {
170
170
  "id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
171
171
  "moduleParts": {
172
- "index.production.js": "b0e2-163"
172
+ "index.production.js": "4cc2-163"
173
173
  },
174
174
  "imported": [],
175
175
  "importedBy": [
176
176
  {
177
- "uid": "b0e2-166"
177
+ "uid": "4cc2-166"
178
178
  },
179
179
  {
180
- "uid": "b0e2-170"
180
+ "uid": "4cc2-170"
181
181
  }
182
182
  ]
183
183
  },
184
- "b0e2-164": {
184
+ "4cc2-164": {
185
185
  "id": "/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
186
186
  "moduleParts": {
187
- "index.production.js": "b0e2-165"
187
+ "index.production.js": "4cc2-165"
188
188
  },
189
189
  "imported": [],
190
190
  "importedBy": [
191
191
  {
192
- "uid": "b0e2-166"
192
+ "uid": "4cc2-166"
193
193
  },
194
194
  {
195
- "uid": "b0e2-170"
195
+ "uid": "4cc2-170"
196
196
  }
197
197
  ]
198
198
  },
199
- "b0e2-166": {
199
+ "4cc2-166": {
200
200
  "id": "/packages/router-core/build/esm/index.js",
201
201
  "moduleParts": {
202
- "index.production.js": "b0e2-167"
202
+ "index.production.js": "4cc2-167"
203
203
  },
204
204
  "imported": [
205
205
  {
206
- "uid": "b0e2-162"
206
+ "uid": "4cc2-162"
207
207
  },
208
208
  {
209
- "uid": "b0e2-164"
209
+ "uid": "4cc2-164"
210
210
  },
211
211
  {
212
- "uid": "b0e2-158"
212
+ "uid": "4cc2-158"
213
213
  }
214
214
  ],
215
215
  "importedBy": [
216
216
  {
217
- "uid": "b0e2-176"
217
+ "uid": "4cc2-176"
218
218
  },
219
219
  {
220
- "uid": "b0e2-170"
220
+ "uid": "4cc2-170"
221
221
  },
222
222
  {
223
- "uid": "b0e2-172"
223
+ "uid": "4cc2-172"
224
224
  },
225
225
  {
226
- "uid": "b0e2-174"
226
+ "uid": "4cc2-174"
227
227
  }
228
228
  ]
229
229
  },
230
- "b0e2-168": {
230
+ "4cc2-168": {
231
231
  "id": "\u0000rollupPluginBabelHelpers.js",
232
232
  "moduleParts": {
233
- "index.production.js": "b0e2-169"
233
+ "index.production.js": "4cc2-169"
234
234
  },
235
235
  "imported": [],
236
236
  "importedBy": [
237
237
  {
238
- "uid": "b0e2-170"
238
+ "uid": "4cc2-170"
239
239
  }
240
240
  ]
241
241
  },
242
- "b0e2-170": {
242
+ "4cc2-170": {
243
243
  "id": "/packages/react-router/src/react.tsx",
244
244
  "moduleParts": {
245
- "index.production.js": "b0e2-171"
245
+ "index.production.js": "4cc2-171"
246
246
  },
247
247
  "imported": [
248
248
  {
249
- "uid": "b0e2-168"
249
+ "uid": "4cc2-168"
250
250
  },
251
251
  {
252
- "uid": "b0e2-179"
252
+ "uid": "4cc2-179"
253
253
  },
254
254
  {
255
- "uid": "b0e2-160"
255
+ "uid": "4cc2-160"
256
256
  },
257
257
  {
258
- "uid": "b0e2-162"
258
+ "uid": "4cc2-162"
259
259
  },
260
260
  {
261
- "uid": "b0e2-164"
261
+ "uid": "4cc2-164"
262
262
  },
263
263
  {
264
- "uid": "b0e2-166"
264
+ "uid": "4cc2-166"
265
265
  }
266
266
  ],
267
267
  "importedBy": [
268
268
  {
269
- "uid": "b0e2-176"
269
+ "uid": "4cc2-176"
270
270
  },
271
271
  {
272
- "uid": "b0e2-172"
272
+ "uid": "4cc2-172"
273
273
  },
274
274
  {
275
- "uid": "b0e2-174"
275
+ "uid": "4cc2-174"
276
276
  }
277
277
  ]
278
278
  },
279
- "b0e2-172": {
279
+ "4cc2-172": {
280
280
  "id": "/packages/react-router/src/scroll-restoration.tsx",
281
281
  "moduleParts": {
282
- "index.production.js": "b0e2-173"
282
+ "index.production.js": "4cc2-173"
283
283
  },
284
284
  "imported": [
285
285
  {
286
- "uid": "b0e2-179"
286
+ "uid": "4cc2-179"
287
287
  },
288
288
  {
289
- "uid": "b0e2-166"
289
+ "uid": "4cc2-166"
290
290
  },
291
291
  {
292
- "uid": "b0e2-170"
292
+ "uid": "4cc2-170"
293
293
  }
294
294
  ],
295
295
  "importedBy": [
296
296
  {
297
- "uid": "b0e2-176"
297
+ "uid": "4cc2-176"
298
298
  }
299
299
  ]
300
300
  },
301
- "b0e2-174": {
301
+ "4cc2-174": {
302
302
  "id": "/packages/react-router/src/awaited.tsx",
303
303
  "moduleParts": {
304
- "index.production.js": "b0e2-175"
304
+ "index.production.js": "4cc2-175"
305
305
  },
306
306
  "imported": [
307
307
  {
308
- "uid": "b0e2-166"
308
+ "uid": "4cc2-166"
309
309
  },
310
310
  {
311
- "uid": "b0e2-170"
311
+ "uid": "4cc2-170"
312
312
  }
313
313
  ],
314
314
  "importedBy": [
315
315
  {
316
- "uid": "b0e2-176"
316
+ "uid": "4cc2-176"
317
317
  }
318
318
  ]
319
319
  },
320
- "b0e2-176": {
320
+ "4cc2-176": {
321
321
  "id": "/packages/react-router/src/index.tsx",
322
322
  "moduleParts": {
323
- "index.production.js": "b0e2-177"
323
+ "index.production.js": "4cc2-177"
324
324
  },
325
325
  "imported": [
326
326
  {
327
- "uid": "b0e2-160"
327
+ "uid": "4cc2-160"
328
328
  },
329
329
  {
330
- "uid": "b0e2-166"
330
+ "uid": "4cc2-166"
331
331
  },
332
332
  {
333
- "uid": "b0e2-170"
333
+ "uid": "4cc2-170"
334
334
  },
335
335
  {
336
- "uid": "b0e2-172"
336
+ "uid": "4cc2-172"
337
337
  },
338
338
  {
339
- "uid": "b0e2-174"
339
+ "uid": "4cc2-174"
340
340
  }
341
341
  ],
342
342
  "importedBy": [],
343
343
  "isEntry": true
344
344
  },
345
- "b0e2-178": {
345
+ "4cc2-178": {
346
346
  "id": "use-sync-external-store/shim/with-selector",
347
347
  "moduleParts": {},
348
348
  "imported": [],
349
349
  "importedBy": [
350
350
  {
351
- "uid": "b0e2-160"
351
+ "uid": "4cc2-160"
352
352
  }
353
353
  ],
354
354
  "isExternal": true
355
355
  },
356
- "b0e2-179": {
356
+ "4cc2-179": {
357
357
  "id": "react",
358
358
  "moduleParts": {},
359
359
  "imported": [],
360
360
  "importedBy": [
361
361
  {
362
- "uid": "b0e2-170"
362
+ "uid": "4cc2-170"
363
363
  },
364
364
  {
365
- "uid": "b0e2-172"
365
+ "uid": "4cc2-172"
366
366
  }
367
367
  ],
368
368
  "isExternal": true
@@ -42,30 +42,24 @@ declare module '@tanstack/router-core' {
42
42
  }
43
43
  }
44
44
  export type RouteProps<TLoader = unknown, TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> = {
45
- useLoader: <TStrict extends boolean = true, TSelected = TLoader>(opts?: {
46
- strict?: TStrict;
45
+ useLoader: <TSelected = TLoader>(opts?: {
47
46
  select?: (search: TLoader) => TSelected;
48
- }) => TStrict extends true ? UseLoaderResult<TSelected> : UseLoaderResult<TSelected> | undefined;
49
- useMatch: <TStrict extends boolean = true, TSelected = TAllContext>(opts?: {
50
- strict?: TStrict;
47
+ }) => UseLoaderResult<TSelected>;
48
+ useMatch: <TSelected = TAllContext>(opts?: {
51
49
  select?: (search: TAllContext) => TSelected;
52
- }) => TStrict extends true ? TSelected : TSelected | undefined;
53
- useContext: <TStrict extends boolean = true, TSelected = TAllContext>(opts?: {
54
- strict?: TStrict;
50
+ }) => TSelected;
51
+ useContext: <TSelected = TAllContext>(opts?: {
55
52
  select?: (search: TAllContext) => TSelected;
56
- }) => TStrict extends true ? TSelected : TSelected | undefined;
57
- useRouteContext: <TStrict extends boolean = true, TSelected = TRouteContext>(opts?: {
58
- strict?: TStrict;
53
+ }) => TSelected;
54
+ useRouteContext: <TSelected = TRouteContext>(opts?: {
59
55
  select?: (search: TRouteContext) => TSelected;
60
- }) => TStrict extends true ? TSelected : TSelected | undefined;
61
- useSearch: <TStrict extends boolean = true, TSelected = TFullSearchSchema>(opts?: {
62
- strict?: TStrict;
56
+ }) => TSelected;
57
+ useSearch: <TSelected = TFullSearchSchema>(opts?: {
63
58
  select?: (search: TFullSearchSchema) => TSelected;
64
- }) => TStrict extends true ? TSelected : TSelected | undefined;
65
- useParams: <TStrict extends boolean = true, TSelected = TAllParams>(opts?: {
66
- strict?: TStrict;
59
+ }) => TSelected;
60
+ useParams: <TSelected = TAllParams>(opts?: {
67
61
  select?: (search: TAllParams) => TSelected;
68
- }) => TStrict extends true ? TSelected : TSelected | undefined;
62
+ }) => TSelected;
69
63
  };
70
64
  export type ErrorRouteProps<TFullSearchSchema extends AnySearchSchema = AnySearchSchema, TAllParams extends AnyPathParams = AnyPathParams, TRouteContext extends AnyContext = AnyContext, TAllContext extends AnyContext = AnyContext> = {
71
65
  error: unknown;
@@ -1300,39 +1300,14 @@
1300
1300
  return parentSearchInfo;
1301
1301
  }
1302
1302
  })();
1303
- Object.assign(match, {
1304
- ...searchInfo
1305
- });
1306
- const contextInfo = (() => {
1307
- try {
1308
- const routeContext = route.options.getContext?.({
1309
- parentContext: parentMatch?.routeContext ?? {},
1310
- context: parentMatch?.context ?? this?.options.context ?? {},
1311
- params: match.params,
1312
- search: match.search
1313
- }) || {};
1314
- const context = {
1315
- ...(parentMatch?.context ?? this?.options.context),
1316
- ...routeContext
1317
- };
1318
- return {
1319
- context,
1320
- routeContext
1321
- };
1322
- } catch (err) {
1323
- route.options.onError?.(err);
1324
- throw err;
1325
- }
1326
- })();
1327
- Object.assign(match, {
1328
- ...contextInfo
1329
- });
1303
+ Object.assign(match, searchInfo);
1330
1304
  });
1331
1305
  return matches;
1332
1306
  };
1333
- loadMatches = async (resolvedMatches, opts) => {
1307
+ loadMatches = async (_resolvedMatches, opts) => {
1308
+ const getFreshMatches = () => _resolvedMatches.map(d => this.getRouteMatch(d.id));
1334
1309
  if (!opts?.preload) {
1335
- resolvedMatches.forEach(match => {
1310
+ getFreshMatches().forEach(match => {
1336
1311
  // Update each match with its latest route data
1337
1312
  this.setRouteMatch(match.id, s => ({
1338
1313
  ...s,
@@ -1352,7 +1327,8 @@
1352
1327
 
1353
1328
  // Check each match middleware to see if the route can be accessed
1354
1329
  try {
1355
- for (const [index, match] of resolvedMatches.entries()) {
1330
+ for (const [index, match] of getFreshMatches().entries()) {
1331
+ const parentMatch = getFreshMatches()[index - 1];
1356
1332
  const route = this.getRoute(match.routeId);
1357
1333
  const handleError = (err, code) => {
1358
1334
  err.routerCode = code;
@@ -1383,10 +1359,21 @@
1383
1359
  }
1384
1360
  let didError = false;
1385
1361
  try {
1386
- await route.options.beforeLoad?.({
1362
+ const routeContext = (await route.options.beforeLoad?.({
1387
1363
  ...match,
1388
- preload: !!opts?.preload
1389
- });
1364
+ preload: !!opts?.preload,
1365
+ parentContext: parentMatch?.routeContext ?? {},
1366
+ context: parentMatch?.context ?? this?.options.context ?? {}
1367
+ })) ?? {};
1368
+ const context = {
1369
+ ...(parentMatch?.context ?? this?.options.context),
1370
+ ...routeContext
1371
+ };
1372
+ this.setRouteMatch(match.id, s => ({
1373
+ ...s,
1374
+ context,
1375
+ routeContext
1376
+ }));
1390
1377
  } catch (err) {
1391
1378
  handleError(err, 'BEFORE_LOAD');
1392
1379
  didError = true;
@@ -1403,7 +1390,7 @@
1403
1390
  }
1404
1391
  throw err;
1405
1392
  }
1406
- const validResolvedMatches = resolvedMatches.slice(0, firstBadMatchIndex);
1393
+ const validResolvedMatches = getFreshMatches().slice(0, firstBadMatchIndex);
1407
1394
  const matchPromises = [];
1408
1395
  validResolvedMatches.forEach((match, index) => {
1409
1396
  matchPromises.push((async () => {
@@ -2200,14 +2187,14 @@
2200
2187
  return useMatch({
2201
2188
  ...opts,
2202
2189
  from: route.id,
2203
- select: d => opts?.select?.(d.context) ?? d.context
2190
+ select: d => opts?.select ? opts.select(d.context) : d.context
2204
2191
  });
2205
2192
  },
2206
2193
  useRouteContext: (opts = {}) => {
2207
2194
  return useMatch({
2208
2195
  ...opts,
2209
2196
  from: route.id,
2210
- select: d => opts?.select?.(d.routeContext) ?? d.routeContext
2197
+ select: d => opts?.select ? opts.select(d.routeContext) : d.routeContext
2211
2198
  });
2212
2199
  },
2213
2200
  useSearch: (opts = {}) => {
@@ -2414,7 +2401,7 @@
2414
2401
  return useRouterState({
2415
2402
  select: state => {
2416
2403
  const matches = state.matches.slice(state.matches.findIndex(d => d.id === matchIds[0]));
2417
- return opts?.select?.(matches) ?? matches;
2404
+ return opts?.select ? opts.select(matches) : matches;
2418
2405
  }
2419
2406
  });
2420
2407
  }
@@ -2432,39 +2419,39 @@
2432
2419
  if (opts?.strict ?? true) {
2433
2420
  invariant(nearestMatchRouteId == matchRouteId, `useMatch("${matchRouteId}") is being called in a component that is meant to render the '${nearestMatchRouteId}' route. Did you mean to 'useMatch("${matchRouteId}", { strict: false })' or 'useRoute("${matchRouteId}")' instead?`);
2434
2421
  }
2435
- const match = useRouterState({
2422
+ const matchSelection = useRouterState({
2436
2423
  select: state => {
2437
2424
  const matches = state.matches;
2438
2425
  const match = opts?.from ? matches.find(d => d.routeId === opts?.from) : matches.find(d => d.id === nearestMatchId);
2439
2426
  invariant(match, `Could not find ${opts?.from ? `an active match from "${opts.from}"` : 'a nearest match!'}`);
2440
- return opts?.select?.(match) ?? match;
2427
+ return opts?.select ? opts.select(match) : match;
2441
2428
  }
2442
2429
  });
2443
- return match;
2430
+ return matchSelection;
2444
2431
  }
2445
2432
  function useLoader(opts) {
2446
2433
  return useMatch({
2447
2434
  ...opts,
2448
- select: match => opts?.select?.(match.loaderData) ?? match.loaderData
2435
+ select: match => opts?.select ? opts?.select(match.loaderData) : match.loaderData
2449
2436
  });
2450
2437
  }
2451
2438
  function useRouterContext(opts) {
2452
2439
  return useMatch({
2453
2440
  ...opts,
2454
- select: match => opts?.select?.(match.context) ?? match.context
2441
+ select: match => opts?.select ? opts.select(match.context) : match.context
2455
2442
  });
2456
2443
  }
2457
2444
  function useRouteContext(opts) {
2458
2445
  return useMatch({
2459
2446
  ...opts,
2460
- select: match => opts?.select?.(match.routeContext) ?? match.routeContext
2447
+ select: match => opts?.select ? opts.select(match.routeContext) : match.routeContext
2461
2448
  });
2462
2449
  }
2463
2450
  function useSearch(opts) {
2464
2451
  return useMatch({
2465
2452
  ...opts,
2466
2453
  select: match => {
2467
- return opts?.select?.(match.search) ?? match.search;
2454
+ return opts?.select ? opts.select(match.search) : match.search;
2468
2455
  }
2469
2456
  });
2470
2457
  }
@@ -2472,7 +2459,7 @@
2472
2459
  return useRouterState({
2473
2460
  select: state => {
2474
2461
  const params = last(state.matches)?.params;
2475
- return opts?.select?.(params) ?? params;
2462
+ return opts?.select ? opts.select(params) : params;
2476
2463
  }
2477
2464
  });
2478
2465
  }