Skip to content

Commit ad81f4e

Browse files
scttcperandrewshie-sentry
authored andcommitted
feat(ui): List available param keys in useParams (#83428)
1 parent 85c70fb commit ad81f4e

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

static/app/utils/useParams.tsx

+35-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,41 @@ import {CUSTOMER_DOMAIN, USING_CUSTOMER_DOMAIN} from 'sentry/constants';
55

66
import {useTestRouteContext} from './useRouteContext';
77

8-
export function useParams<P = Record<string, string>>(): P {
8+
/**
9+
* List of keys used in routes.tsx `/example/:paramKey/...`
10+
*
11+
* Prevents misspelling of param keys
12+
*/
13+
type ParamKeys =
14+
| 'apiKey'
15+
| 'dataExportId'
16+
| 'eventId'
17+
| 'groupId'
18+
| 'id'
19+
| 'installationId'
20+
| 'integrationSlug'
21+
| 'issueId'
22+
| 'memberId'
23+
| 'orgId'
24+
| 'projectId'
25+
| 'release'
26+
| 'scrubbingId'
27+
| 'searchId'
28+
| 'sentryAppSlug'
29+
| 'shareId'
30+
| 'spanSlug'
31+
| 'teamId'
32+
| 'widgetIndex';
33+
34+
/**
35+
* Get params from the current route. Param availability depends on the current route.
36+
*
37+
* @example
38+
* ```tsx
39+
* const params = useParams<{projectId: string}>();
40+
* ```
41+
*/
42+
export function useParams<P = Partial<Record<ParamKeys, string | undefined>>>(): P {
943
// When running in test mode we still read from the legacy route context to
1044
// keep test compatability while we fully migrate to react router 6
1145
const testRouteContext = useTestRouteContext();

static/app/views/profiling/continuousProfileFlamegraph.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function ContinuousProfileFlamegraph(): React.ReactElement {
8989
<FlamegraphStateProvider initialState={initialFlamegraphPreferencesState}>
9090
<ProfileGroupTypeProvider
9191
input={profiles.type === 'resolved' ? profiles.data : null}
92-
traceID={params.eventID!}
92+
traceID={params.eventId!}
9393
>
9494
<FlamegraphThemeProvider>
9595
<FlamegraphStateQueryParamSync />

static/app/views/profiling/profileFlamechart.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function ProfileFlamegraph(): React.ReactElement {
9090
<FlamegraphStateProvider initialState={initialFlamegraphPreferencesState}>
9191
<ProfileGroupTypeProvider
9292
input={profiles.type === 'resolved' ? profiles.data : null}
93-
traceID={params.eventID!}
93+
traceID={params.eventId!}
9494
>
9595
<FlamegraphThemeProvider>
9696
<FlamegraphStateQueryParamSync />

0 commit comments

Comments
 (0)