fix(webapp): preserve React hook order (#4681)

## Summary

Call dashboard hooks unconditionally so components keep a stable hook
order when their props change.

Base: [#4680](https://github.com/triggerdotdev/trigger.dev/pull/4680)
This commit is contained in:
Chris Arderne
2026-08-19 08:29:00 +01:00
committed by GitHub
parent c3016eb9e4
commit 1aeb356b9e
3 changed files with 13 additions and 17 deletions
+2 -2
View File
@@ -57,7 +57,7 @@ function useApiUrl() {
}
}
function getApiUrlArg() {
function useApiUrlArg() {
const apiUrl = useApiUrl();
return apiUrl ? `-a ${apiUrl}` : undefined;
}
@@ -70,7 +70,7 @@ type TabsProps = {
export function InitCommandV3({ title }: TabsProps) {
const project = useProject();
const projectRef = project.externalRef;
const apiUrlArg = getApiUrlArg();
const apiUrlArg = useApiUrlArg();
const triggerCliTag = useTriggerCliTag();
const initCommandParts = [`trigger.dev@${triggerCliTag}`, "init", `-p ${projectRef}`, apiUrlArg];
+9 -11
View File
@@ -234,17 +234,15 @@ export function TabButton({
} & React.ButtonHTMLAttributes<HTMLButtonElement>) {
const ref = useRef<HTMLButtonElement>(null);
if (shortcut) {
useShortcutKeys({
shortcut: shortcut,
action: () => {
if (ref.current) {
ref.current.click();
}
},
disabled: props.disabled,
});
}
useShortcutKeys({
shortcut,
action: () => {
if (ref.current) {
ref.current.click();
}
},
disabled: props.disabled,
});
const title = variant === "title";
+2 -4
View File
@@ -23,11 +23,9 @@ export function useTypedMatchesData<T = AppData>({
id: string;
matches?: UIMatch[];
}): UseDataFunctionReturn<T> | undefined {
if (!matches) {
matches = useMatches();
}
const routeMatches = useMatches();
return useTypedDataFromMatches<T>({ id, matches });
return useTypedDataFromMatches<T>({ id, matches: matches ?? routeMatches });
}
function useTypedMatchData<T = AppData>(