|
3 | 3 | * routing object in that it doesn't take a rendered component, but instead a
|
4 | 4 | * component type and handles the rendering itself.
|
5 | 5 | */
|
6 |
| -export interface SentryRouteObject { |
| 6 | +interface BaseRouteObject { |
7 | 7 | /**
|
8 | 8 | * child components to render under this route
|
9 | 9 | */
|
10 | 10 | children?: SentryRouteObject[];
|
11 |
| - /** |
12 |
| - * A react component to render or a import promise that will be lazily loaded |
13 |
| - */ |
14 |
| - component?: React.ComponentType<any>; |
15 | 11 | /**
|
16 | 12 | * Only enable this route when USING_CUSTOMER_DOMAIN is enabled
|
17 | 13 | */
|
18 | 14 | customerDomainOnlyRoute?: true;
|
| 15 | + /** |
| 16 | + * Injects react router 3 style router props to the component. |
| 17 | + * Including an `Outlet` component as a child element. |
| 18 | + */ |
| 19 | + deprecatedRouteProps?: never; |
19 | 20 | /**
|
20 | 21 | * Is a index route
|
21 | 22 | */
|
@@ -52,9 +53,45 @@ export interface SentryRouteObject {
|
52 | 53 | * withDomainRedirect respectively.
|
53 | 54 | */
|
54 | 55 | withOrgPath?: boolean;
|
| 56 | +} |
55 | 57 |
|
56 |
| - // XXX(epurkhiser): In the future we can introduce a `requiresLegacyProps` |
57 |
| - // prop here that will pass in the react-router 3 style routing props. We can |
58 |
| - // use this as a way to slowly get rid of react router 3 style prosp in favor |
59 |
| - // of using the route hooks. |
| 58 | +/** |
| 59 | + * Enforces that these props are not expected by the component. |
| 60 | + */ |
| 61 | +type NoRouteProps = { |
| 62 | + [key: string | number | symbol]: any; |
| 63 | + children?: never; |
| 64 | + location?: never; |
| 65 | + params?: never; |
| 66 | + route?: never; |
| 67 | + routeParams?: never; |
| 68 | + router?: never; |
| 69 | + routes?: never; |
| 70 | +}; |
| 71 | + |
| 72 | +interface DeprecatedPropRoute extends Omit<BaseRouteObject, 'deprecatedRouteProps'> { |
| 73 | + /** |
| 74 | + * A react component that accepts legacy router props (location, params, router, etc.) |
| 75 | + */ |
| 76 | + component: React.ComponentType<any>; |
| 77 | + /** |
| 78 | + * Passes legacy route props to the component. |
| 79 | + */ |
| 80 | + deprecatedRouteProps: true; |
60 | 81 | }
|
| 82 | + |
| 83 | +interface RouteObject extends BaseRouteObject { |
| 84 | + /** |
| 85 | + * A react component to render. Components that expect RouteComponentProps are |
| 86 | + * not allowed here. Use deprecatedRouteProps: true on legacy components. New |
| 87 | + * components should use the `use{Params,Location}` hooks. |
| 88 | + * Components that expect RouteComponentProps are not allowed here - use deprecatedRouteProps: true instead. |
| 89 | + */ |
| 90 | + component: React.ComponentType<NoRouteProps>; |
| 91 | +} |
| 92 | + |
| 93 | +interface NoComponentRoute extends BaseRouteObject { |
| 94 | + component?: never; |
| 95 | +} |
| 96 | + |
| 97 | +export type SentryRouteObject = RouteObject | DeprecatedPropRoute | NoComponentRoute; |
0 commit comments