Skip to content

Commit 6ef925e

Browse files
committed
Wrap sidebar in a suspense so useSearchParams doesn't blow up
1 parent 7357390 commit 6ef925e

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

typescript-sdk/apps/dojo/src/components/layout/main-layout.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import React, { useState } from "react";
3+
import React, { Suspense, useState } from "react";
44
import { ViewerLayout } from "@/components/layout/viewer-layout";
55
import { Sidebar } from "@/components/sidebar/sidebar";
66

@@ -9,10 +9,7 @@ import featureConfig from "@/config";
99

1010
export function MainLayout({ children }: { children: React.ReactNode }) {
1111
const pathname = usePathname();
12-
const searchParams = useSearchParams();
1312

14-
const sidebarDisabled = searchParams.get("sidebar") === "disabled";
15-
const integrationPickerDisabled = searchParams.get("picker") === "false";
1613

1714
// Extract the current demo ID from the pathname
1815
const pathParts = pathname.split("/");
@@ -23,7 +20,10 @@ export function MainLayout({ children }: { children: React.ReactNode }) {
2320
<ViewerLayout showFileTree={false} showCodeEditor={false}>
2421
<div className="flex h-full w-full overflow-hidden">
2522
{/* Sidebar */}
26-
{!sidebarDisabled && <Sidebar activeTab={"preview"} readmeContent={""} pickerDisabled={integrationPickerDisabled} />}
23+
<Suspense>
24+
<MaybeSidebar/>
25+
</Suspense>
26+
2727

2828
{/* Content */}
2929
<div className="flex-1 overflow-auto">
@@ -33,3 +33,12 @@ export function MainLayout({ children }: { children: React.ReactNode }) {
3333
</ViewerLayout>
3434
);
3535
}
36+
37+
function MaybeSidebar() {
38+
const searchParams = useSearchParams();
39+
40+
const sidebarDisabled = searchParams.get("sidebar") === "disabled";
41+
const integrationPickerDisabled = searchParams.get("picker") === "false";
42+
43+
return !sidebarDisabled && <Sidebar activeTab={"preview"} readmeContent={""} pickerDisabled={integrationPickerDisabled} />;
44+
}

0 commit comments

Comments
 (0)