From c11395ece16b2b9501ddb97f6de2f8971e40be39 Mon Sep 17 00:00:00 2001 From: Darius Cepulis Date: Tue, 24 Feb 2026 15:21:55 -0600 Subject: [PATCH] fix(site): work around Astro SSR false "Invalid hook call" warnings (#600) Co-authored-by: Claude Opus 4.6 --- site/src/components/docs/PreferenceSync.tsx | 4 +++- site/src/components/docs/PreferenceUpdater.tsx | 4 +++- site/src/components/docs/TableOfContents/index.tsx | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/site/src/components/docs/PreferenceSync.tsx b/site/src/components/docs/PreferenceSync.tsx index 33e5ae9b..eb99cb50 100644 --- a/site/src/components/docs/PreferenceSync.tsx +++ b/site/src/components/docs/PreferenceSync.tsx @@ -29,5 +29,7 @@ export function PreferenceSync() { } }, [framework]); - return null; + // Workaround: Astro SSR logs false "Invalid hook call" when a React + // component with hooks returns null. See withastro/astro#12283. + return <>; } diff --git a/site/src/components/docs/PreferenceUpdater.tsx b/site/src/components/docs/PreferenceUpdater.tsx index 736a14a2..7532e3d9 100644 --- a/site/src/components/docs/PreferenceUpdater.tsx +++ b/site/src/components/docs/PreferenceUpdater.tsx @@ -24,5 +24,7 @@ export function PreferenceUpdater({ currentFramework }: PreferenceUpdaterProps) styleStore.set(style); }, [currentFramework]); - return null; + // Workaround: Astro SSR logs false "Invalid hook call" when a React + // component with hooks returns null. See withastro/astro#12283. + return <>; } diff --git a/site/src/components/docs/TableOfContents/index.tsx b/site/src/components/docs/TableOfContents/index.tsx index ea60d43f..67b835d8 100644 --- a/site/src/components/docs/TableOfContents/index.tsx +++ b/site/src/components/docs/TableOfContents/index.tsx @@ -12,7 +12,9 @@ export function TableOfContents({ headings }: TableOfContentsProps) { const activeId = useActiveHeading(filteredHeadings); if (filteredHeadings.length === 0) { - return null; + // Workaround: Astro SSR logs false "Invalid hook call" when a React + // component with hooks returns null. See withastro/astro#12283. + return <>; } return (