@tanstack/react-router 0.0.1-alpha.3 → 0.0.1-alpha.4
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/build/cjs/react-router/src/index.js +6 -18
- package/build/cjs/react-router/src/index.js.map +1 -1
- package/build/cjs/router-core/build/esm/index.js +85 -54
- package/build/cjs/router-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +90 -73
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +29 -29
- package/build/umd/index.development.js +85 -70
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +30 -33
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-router",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "0.0.1-alpha.
|
|
4
|
+
"version": "0.0.1-alpha.4",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "tanstack/router",
|
|
7
7
|
"homepage": "https://react-router.tanstack.com/",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@babel/runtime": "^7.16.7",
|
|
43
|
-
"@tanstack/router-core": "0.0.1-alpha.
|
|
43
|
+
"@tanstack/router-core": "0.0.1-alpha.4",
|
|
44
44
|
"use-sync-external-store": "^1.2.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
package/src/index.tsx
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
AnyRoute,
|
|
7
7
|
RootRouteId,
|
|
8
8
|
rootRouteId,
|
|
9
|
-
Route,
|
|
10
9
|
Router,
|
|
11
10
|
} from '@tanstack/router-core'
|
|
12
11
|
import {
|
|
@@ -29,6 +28,7 @@ import {
|
|
|
29
28
|
ResolveRelativePath,
|
|
30
29
|
NoInfer,
|
|
31
30
|
ToOptions,
|
|
31
|
+
invariant,
|
|
32
32
|
} from '@tanstack/router-core'
|
|
33
33
|
|
|
34
34
|
export * from '@tanstack/router-core'
|
|
@@ -323,48 +323,45 @@ export function createReactRouter<
|
|
|
323
323
|
useRoute: (routeId) => {
|
|
324
324
|
const route = router.getRoute(routeId)
|
|
325
325
|
useRouterSubscription(router)
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
}
|
|
326
|
+
invariant(
|
|
327
|
+
route,
|
|
328
|
+
`Could not find a route for route "${
|
|
329
|
+
routeId as string
|
|
330
|
+
}"! Did you forget to add it to your route config?`,
|
|
331
|
+
)
|
|
333
332
|
return route
|
|
334
333
|
},
|
|
335
334
|
useMatch: (routeId) => {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
335
|
+
invariant(
|
|
336
|
+
routeId !== rootRouteId,
|
|
337
|
+
`"${rootRouteId}" cannot be used with useMatch! Did you mean to useRoute("${rootRouteId}")?`,
|
|
338
|
+
)
|
|
339
|
+
|
|
341
340
|
const runtimeMatch = useMatch()
|
|
342
341
|
const match = router.state.matches.find((d) => d.routeId === routeId)
|
|
343
342
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
)
|
|
362
|
-
}
|
|
343
|
+
invariant(
|
|
344
|
+
match,
|
|
345
|
+
`Could not find a match for route "${
|
|
346
|
+
routeId as string
|
|
347
|
+
}" being rendered in this component!`,
|
|
348
|
+
)
|
|
349
|
+
|
|
350
|
+
invariant(
|
|
351
|
+
runtimeMatch.routeId == match?.routeId,
|
|
352
|
+
`useMatch('${
|
|
353
|
+
match?.routeId as string
|
|
354
|
+
}') is being called in a component that is meant to render the '${
|
|
355
|
+
runtimeMatch.routeId
|
|
356
|
+
}' route. Did you mean to 'useRoute(${
|
|
357
|
+
match?.routeId as string
|
|
358
|
+
})' instead?`,
|
|
359
|
+
)
|
|
363
360
|
|
|
364
361
|
useRouterSubscription(router)
|
|
365
362
|
|
|
366
363
|
if (!match) {
|
|
367
|
-
|
|
364
|
+
invariant('Match not found!')
|
|
368
365
|
}
|
|
369
366
|
|
|
370
367
|
return match
|