Skip to content

Commit 5f248cd

Browse files
committed
fix(webapp): preserve React hook order
1 parent be0c85c commit 5f248cd

3 files changed

Lines changed: 13 additions & 17 deletions

File tree

apps/webapp/app/components/SetupCommands.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function useApiUrl() {
5757
}
5858
}
5959

60-
function getApiUrlArg() {
60+
function useApiUrlArg() {
6161
const apiUrl = useApiUrl();
6262
return apiUrl ? `-a ${apiUrl}` : undefined;
6363
}
@@ -70,7 +70,7 @@ type TabsProps = {
7070
export function InitCommandV3({ title }: TabsProps) {
7171
const project = useProject();
7272
const projectRef = project.externalRef;
73-
const apiUrlArg = getApiUrlArg();
73+
const apiUrlArg = useApiUrlArg();
7474
const triggerCliTag = useTriggerCliTag();
7575

7676
const initCommandParts = [`trigger.dev@${triggerCliTag}`, "init", `-p ${projectRef}`, apiUrlArg];

apps/webapp/app/components/primitives/Tabs.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -234,17 +234,15 @@ export function TabButton({
234234
} & React.ButtonHTMLAttributes<HTMLButtonElement>) {
235235
const ref = useRef<HTMLButtonElement>(null);
236236

237-
if (shortcut) {
238-
useShortcutKeys({
239-
shortcut: shortcut,
240-
action: () => {
241-
if (ref.current) {
242-
ref.current.click();
243-
}
244-
},
245-
disabled: props.disabled,
246-
});
247-
}
237+
useShortcutKeys({
238+
shortcut,
239+
action: () => {
240+
if (ref.current) {
241+
ref.current.click();
242+
}
243+
},
244+
disabled: props.disabled,
245+
});
248246

249247
const title = variant === "title";
250248

apps/webapp/app/hooks/useTypedMatchData.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ export function useTypedMatchesData<T = AppData>({
2323
id: string;
2424
matches?: UIMatch[];
2525
}): UseDataFunctionReturn<T> | undefined {
26-
if (!matches) {
27-
matches = useMatches();
28-
}
26+
const routeMatches = useMatches();
2927

30-
return useTypedDataFromMatches<T>({ id, matches });
28+
return useTypedDataFromMatches<T>({ id, matches: matches ?? routeMatches });
3129
}
3230

3331
function useTypedMatchData<T = AppData>(

0 commit comments

Comments
 (0)