ModalProvider breaks the layout
here's ModalProvider code:
"use client";
import { CreateServerModal } from "@/components/modals/create-server-modal";
import { useEffect, useState } from "react";
export const ModalProvider = () => {
const [isMounted, setIsMounted] = useState(false);
useEffect(() => {
setIsMounted(true);
}, []);
if (!isMounted) {
return null;
}
return (
#Unknown Channel
<CreateServerModal />
</>
)
};
If you are having an issue with disappearing navbar & sidebar upon leaving the server, deleting the server etc.
You can fix this by moving UploadThing's styles into global.css at the end of the file instead of in the react component.
Step 1:
- Remove the import for upload-thing styles inside file-upload.tsx component
- DELETE => import "@uploadthing/react/styles.css";
Step 2:
- Add the import at the bottom of the globals.css file instead
// globals.css
...
@import "~@uploadthing/react/styles.css";
Step 3 (optional):
- Wrap the tailwind config with "withUt":
// tailwind.config.js
const { withUt } = require("uploadthing/tw");
module.exports = withUt({
...leave everything the same
});
102 Replies
- Code
- How to import
- Parent component
I think the error is partly how you've defined the exports in your modules. I'd like to verify this.
use-modal-store.ts file from hooks folder:
import { create } from 'zustand';
export type ModalType = "createServer";
interface ModalStore {
type: ModalType | null;
isOpen: boolean;
onOpen: (type: ModalType) => void;
onClose: () => void;
}
export const useModal = create<ModalStore>((set) => ({
type: null,
isOpen: false,
onOpen: (type) => set({ isOpen: true, type }),
onClose: () => set({ type: null, isOpen: false })
}));
modal-provider.tsx
"use client";
import { CreateServerModal } from "@/components/modals/create-server-modal";
import { useEffect, useState } from "react";
export const ModalProvider = () => {
const [isMounted, setIsMounted] = useState(false);
useEffect(() => {
setIsMounted(true);
}, []);
if (!isMounted) {
return null;
}
return (
<>
<CreateServerModal />
</>
)
};
https://nextjs.org/docs/app/building-your-application/routing/route-groups
But in summary, within the path group, any file that is page.tsx the path segment "/" as long as it is not inside a directory.
import "./globals.css";
import type { Metadata } from "next";
import { Open_Sans } from "next/font/google";
import { ClerkProvider } from '@clerk/nextjs';
import { enUS } from '@clerk/localizations';
import { cn } from "@/lib/utils";
import { ThemeProvider } from "@/components/providers/theme-provider";
import { ModalProvider } from "@/components/providers/modal-provider";
const font = Open_Sans({
subsets: ['latin']
});
export const metadata: Metadata = {
title: "Khabar App",
description: "Generated by create next app",
};
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<ClerkProvider localization={localization} >
<html lang="en" suppressHydrationWarning>
<body className={cn(
font.className,
"bg-white dark:bg-[#0F172B]"
)}>
<ThemeProvider
attribute="class"
defaultTheme="dark"
enableSystem={false}
storageKey="khabar-theme"
>
<ModalProvider />
{children}
</ThemeProvider>
</body>
</html>
</ClerkProvider>
);
}
"use client";
import { Plus } from "lucide-react";
import { ActionTooltip } from "@/components/action-tooltip";
import { useModal } from "@/hooks/use-modal-store";
export const NavigationAction = () => {
const { onOpen } = useModal();
return (
<div>
<ActionTooltip side="right" align="center" label="New server">
<button
onClick = {() => onOpen("createServer")}
className="group flex items-center">
<div className="flex mx-3 h-[48px] w-[48px] rounded-[24px] group-hover:rounded-[16px] transition-all overflow-hidden items-center justify-center bg-slate-50 dark:bg-slate-700 group-hover:bg-orange-500">
<Plus
className="group-hover:text-white transition text-orange-500"
size={25}
/>
</div>
</button>
</ActionTooltip>
</div>
)
}
https://www.youtube.com/watch?v=ZbX4Ok9YX94
export default function RootLayout({
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<ClerkProvider localization={localization /* this variable */}>
<html lang="en" suppressHydrationWarning>
<body className={cn(font.className, "bg-white dark:bg-[#0F172B]")}>
<ThemeProvider
attribute="class"
defaultTheme="dark"
enableSystem={false}
storageKey="khabar-theme"
>
<ModalProvider />
{children}
</ThemeProvider>
</body>
</html>
</ClerkProvider>
);
}
import "./globals.css";
import type { Metadata } from "next";
import { Open_Sans } from "next/font/google";
import { ClerkProvider } from "@clerk/nextjs";
import { enUS } from "@clerk/localizations";
import { cn } from "@/lib/utils";
import { ThemeProvider } from "@/components/providers/theme-provider";
import { ModalProvider } from "@/components/providers/modal-provider";
At no time do you import location
const localization = {
...enUS,
signUp: {
start: {
title: 'Жаңа аккаунт',
subtitle: '{{applicationName}} жалғастыру үшін тіркелу керек',
actionText: 'Аккаунт бар ма?',
actionLink: 'Кіру',
},
emailLink: {
title: 'Поштаңызды растаңыз',
subtitle: '{{applicationName}} жалғастыру үшін',
resendButton: 'Хат алмадыңыз ба? Қайта жіберу',
},
},
dividerText: 'немесе',
formFieldLabelusername: 'Пайдаланушы аты',
formFieldLabelemailAddress: 'Пошта',
formFieldInputPlaceholderemailAddress: 'Поштаңызды енгізіңіз',
formFieldLabelpassword: 'Құпия сөз',
formFieldInputPlaceholderpassword: 'Құпия сөзді енгізіңіз',
formButtonPrimary: 'Жалғастыру',
formFieldLabelemailAddress_username: 'Пошта немесе пайдаланушы аты',
formFieldInputPlaceholder__emailAddress_username: 'Пошта немесе пайдаланушы атын енгізіңіз',
socialButtonsBlockButton: '{{provider|titleize}} арқылы кіру',
form_param_format_invalid: 'Енгізілген сөз қате форматта. Тексеріп, түзетіңіз.',
signIn: {
start: {
actionLink: 'Тіркелу',
actionText: 'Аккаунт жоқ па?',
subtitle: 'Қош келдіңіз! Жалғастыру үшін аккаунтыңызға кіріңіз',
subtitleCombined: undefined,
title: '{{applicationName}} кіру',
},
}
};

import { enUS as localization } from "@clerk/localizations";
import { NavigationSidebar } from "@/components/navigation/navigation-sidebar";
const MainLayout = async ({
children
}: {
children: React.ReactNode;
}) => {
return (
<div className="h-full">
<div className="hidden md:flex h-full w-[72px] z-30 flex-col fixed inset-y-0">
<NavigationSidebar />
</div>
<main className="md:pl-[72px] h-full">{children}</main>
</div>
);
}
export default MainLayout;
This will highlight the element.
https://ui.shadcn.com/blocks#sidebar-07
I know this doesn't directly solve your problem (and it still seems like a styling issue to me), but I hope it can help relieve this stress you're probably carrying.

If you are having an issue with disappearing navbar & sidebar upon leaving the server, deleting the server etc.
You can fix this by moving UploadThing's styles into global.css at the end of the file instead of in the react component.
Step 1:
- Remove the import for upload-thing styles inside file-upload.tsx component
- DELETE => import "@uploadthing/react/styles.css";
Step 2:
- Add the import at the bottom of the globals.css file instead
// globals.css
...
@import "~@uploadthing/react/styles.css";
Step 3 (optional):
- Wrap the tailwind config with "withUt":
// tailwind.config.js
const { withUt } = require("uploadthing/tw");
module.exports = withUt({
...leave everything the same
});