We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3796bd3 commit 7454abdCopy full SHA for 7454abd
1 file changed
packages/components/src/ui/sidebar.tsx
@@ -55,7 +55,17 @@ const SidebarContext = React.createContext<SidebarContextProps | null>(null)
55
function useSidebar() {
56
const context = React.useContext(SidebarContext)
57
if (!context) {
58
- throw new Error("useSidebar must be used within a SidebarProvider.")
+ // Return default values when no provider exists (e.g., during SSR/prerendering)
59
+ // This allows components to gracefully degrade without breaking the build
60
+ return {
61
+ state: "expanded" as const,
62
+ open: true,
63
+ setOpen: () => {},
64
+ openMobile: false,
65
+ setOpenMobile: () => {},
66
+ isMobile: false,
67
+ toggleSidebar: () => {},
68
+ }
69
}
70
71
return context
0 commit comments