1
1
import React from 'react'
2
2
3
- import type {
4
- RouteMatch ,
5
- RouteObject ,
6
- RouteProps as RRRouteProps ,
7
- } from 'react-router'
8
- import { Navigate , Route as RRRoute , Routes } from 'react-router-dom'
3
+ import type { RouteMatch , RouteObject } from 'react-router'
4
+ import { Navigate , Route , Routes } from 'react-router-dom'
9
5
10
6
import InstanceCreatePage from './pages/instances/create'
11
7
import InstanceStorage from './pages/instances/Storage'
@@ -22,20 +18,6 @@ import OrgLayout from './layouts/OrgLayout'
22
18
import ProjectLayout from './layouts/ProjectLayout'
23
19
import InstanceLayout from './layouts/InstanceLayout'
24
20
25
- // function arm lets us make labels that depend on route params
26
- type Crumb = string | ( ( m : RouteMatch ) => string )
27
-
28
- type RouteProps = RRRouteProps & {
29
- crumb ?: Crumb
30
- }
31
-
32
- export type CustomRouteObject = RouteObject & {
33
- crumb ?: Crumb
34
- }
35
-
36
- /** Custom `<Route>` that accepts whatever props we want. */
37
- const Route = ( props : RouteProps ) => < RRRoute { ...props } />
38
-
39
21
/*
40
22
* We are doing something a little unorthodox with the route config here. We
41
23
* realized that tagging nodes in the route tree with arbitrary data is very
@@ -49,6 +31,9 @@ const Route = (props: RouteProps) => <RRRoute {...props} />
49
31
* The config ends up being a bit more complicated that it would otherwise be
50
32
* because, e.g., we have to do `orgs` and `:orgName` separately in order to get
51
33
* a crumb for each; `orgs/:orgName` would otherwise be ok.
34
+ *
35
+ * Note that `crumb` is defined via patched react-router types in
36
+ * `types/react-router.d.ts`
52
37
*/
53
38
54
39
/* eslint-disable @typescript-eslint/no-non-null-assertion */
@@ -155,10 +140,8 @@ export const routes = (
155
140
* in order to be able to put `crumb` prop directly on the <Route> elements
156
141
* https://github.com/remix-run/react-router/blob/174fb105ee/packages/react-router/index.tsx#L685
157
142
* */
158
- function createRoutesFromChildren (
159
- children : React . ReactNode
160
- ) : CustomRouteObject [ ] {
161
- const routes : CustomRouteObject [ ] = [ ]
143
+ function createRoutesFromChildren ( children : React . ReactNode ) : RouteObject [ ] {
144
+ const routes : RouteObject [ ] = [ ]
162
145
163
146
React . Children . forEach ( children , ( element ) => {
164
147
if ( ! React . isValidElement ( element ) ) {
@@ -174,7 +157,7 @@ function createRoutesFromChildren(
174
157
}
175
158
176
159
// only real difference from the original: allow arbitrary props
177
- const route : CustomRouteObject = { ...element . props }
160
+ const route : RouteObject = { ...element . props }
178
161
179
162
if ( element . props . children ) {
180
163
route . children = createRoutesFromChildren ( element . props . children )
0 commit comments