Skip to content

Commit 8cb2e7b

Browse files
authored
Fix build by wrapping sidebar in a suspense (#221)
* Wrap sidebar in a suspense so useSearchParams doesn't blow up * Cleanup unused code from main layout
1 parent 7357390 commit 8cb2e7b

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,20 @@
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

7-
import { usePathname, useSearchParams } from "next/navigation";
8-
import featureConfig from "@/config";
7+
import { useSearchParams } from "next/navigation";
98

109
export function MainLayout({ children }: { children: React.ReactNode }) {
11-
const pathname = usePathname();
12-
const searchParams = useSearchParams();
13-
14-
const sidebarDisabled = searchParams.get("sidebar") === "disabled";
15-
const integrationPickerDisabled = searchParams.get("picker") === "false";
16-
17-
// Extract the current demo ID from the pathname
18-
const pathParts = pathname.split("/");
19-
const currentFeatureId = pathParts[pathParts.length - 1];
20-
const currentFeature = featureConfig.find((d) => d.id === currentFeatureId);
21-
2210
return (
2311
<ViewerLayout showFileTree={false} showCodeEditor={false}>
2412
<div className="flex h-full w-full overflow-hidden">
2513
{/* Sidebar */}
26-
{!sidebarDisabled && <Sidebar activeTab={"preview"} readmeContent={""} pickerDisabled={integrationPickerDisabled} />}
14+
<Suspense>
15+
<MaybeSidebar/>
16+
</Suspense>
17+
2718

2819
{/* Content */}
2920
<div className="flex-1 overflow-auto">
@@ -33,3 +24,12 @@ export function MainLayout({ children }: { children: React.ReactNode }) {
3324
</ViewerLayout>
3425
);
3526
}
27+
28+
function MaybeSidebar() {
29+
const searchParams = useSearchParams();
30+
31+
const sidebarDisabled = searchParams.get("sidebar") === "disabled";
32+
const integrationPickerDisabled = searchParams.get("picker") === "false";
33+
34+
return !sidebarDisabled && <Sidebar activeTab={"preview"} readmeContent={""} pickerDisabled={integrationPickerDisabled} />;
35+
}

0 commit comments

Comments
 (0)