11"use client" ;
22
3- import React , { useState } from "react" ;
3+ import React , { Suspense , useState } from "react" ;
44import { ViewerLayout } from "@/components/layout/viewer-layout" ;
55import { Sidebar } from "@/components/sidebar/sidebar" ;
66
@@ -9,10 +9,7 @@ import featureConfig from "@/config";
99
1010export 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