File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
packages/components/src/ui Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -52,10 +52,22 @@ type SidebarContextProps = {
5252
5353const SidebarContext = React . createContext < SidebarContextProps | null > ( null )
5454
55+ // Default sidebar state for when no provider exists (e.g., during SSR/prerendering)
56+ const DEFAULT_SIDEBAR_STATE : SidebarContextProps = {
57+ state : "expanded" ,
58+ open : true ,
59+ setOpen : ( ) => { } ,
60+ openMobile : false ,
61+ setOpenMobile : ( ) => { } ,
62+ isMobile : false ,
63+ toggleSidebar : ( ) => { } ,
64+ }
65+
5566function useSidebar ( ) {
5667 const context = React . useContext ( SidebarContext )
5768 if ( ! context ) {
58- throw new Error ( "useSidebar must be used within a SidebarProvider." )
69+ // Return default values to allow components to gracefully degrade without breaking the build
70+ return DEFAULT_SIDEBAR_STATE
5971 }
6072
6173 return context
You can’t perform that action at this time.
0 commit comments