-
-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DashboardLayout] color-scheme
hydration warnings
#4491
Comments
this is my Nextjs layout.jsx code import { AppRouterCacheProvider } from '@mui/material-nextjs/v15-appRouter';
Provider
import localFont from "next/font/local";
import "./globals.css";
import Provider from '../util/Providers';
import DashboardLayoutBasic from '@/components/dashboardLayout/page';
const geistSans = localFont({
src: "./fonts/GeistVF.woff",
variable: "--font-geist-sans",
weight: "100 900",
});
const geistMono = localFont({
src: "./fonts/GeistMonoVF.woff",
variable: "--font-geist-mono",
weight: "100 900",
});
export const metadata = {
title: "one7sportsAdminPanel_Frontend",
description: "Admin panel frontend.",
};
export default function RootLayout({ children }) {
return (
<html lang="en">
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
<Provider>
<AppRouterCacheProvider>
<DashboardLayoutBasic>
{children}
</DashboardLayoutBasic>
</AppRouterCacheProvider>
</Provider>
</body>
</html>
);
} |
this is my another component named DashboardLayoutBasic which i importing in layout.jsx |
Hey @ashishjaswal2002, please provide a playground or repository so we can take a look. |
not working i am using this as an example https://mui.com/toolpad/core/introduction/examples/ |
Is it possible to create a minimal reproduction in CodeSandbox to make it possible to debug this? By minimal reproduction, I mean adding the minimum amount of code it takes to reproduce this error |
I m using next 15 i think on sand box it has different version |
You can create your own sandbox to demonstrate the error |
@bharatkashyap did you find the error |
@bharatkashyap i figured out the issue i wrap the childrens in themeProvider but the issue is Where should i write my navigation or AppProvider component which provides navigation? import React from "react";
import { AppRouterCacheProvider } from "@mui/material-nextjs/v15-appRouter";
import localFont from "next/font/local";
import "./globals.css";
import Provider from "../util/Providers";
import { AppProvider } from "@toolpad/core/nextjs";
import DashboardIcon from "@mui/icons-material/Dashboard";
import ShoppingCartIcon from "@mui/icons-material/ShoppingCart";
import demoTheme from "@/theme/theme";
import {ThemeProvider} from '@mui/material/styles'
const NAVIGATION = [
{
kind: "header",
title: "Main items",
},
{
title: "Dashboard",
icon: <DashboardIcon />,
},
{
segment: "orders",
title: "Orders",
icon: <ShoppingCartIcon />,
},
];
const geistSans = localFont({
src: "./fonts/GeistVF.woff",
variable: "--font-geist-sans",
weight: "100 900",
});
const geistMono = localFont({
src: "./fonts/GeistMonoVF.woff",
variable: "--font-geist-mono",
weight: "100 900",
});
export const metadata = {
title: "Something",
description: "Spometjing",
};
export default function RootLayout({ children }) {
return (
<html lang="en" >
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`} >
<Provider>
<AppRouterCacheProvider options={{ enableCssLayer: true }} >
<ThemeProvider theme={demoTheme}>
{children}
</ThemeProvider>
</AppRouterCacheProvider>
</Provider>
</body>
</html>
);
} |
if i add App provider inside themeProvider it gives me hydration error
|
@aarongarciah please give me guidance. |
Not sure if I understand your need correctly but you should be able to pass the theme object directly to the |
import React from "react";
import { AppRouterCacheProvider } from "@mui/material-nextjs/v15-appRouter";
import localFont from "next/font/local";
import "./globals.css";
import Provider from "../util/Providers";
import DashboardIcon from "@mui/icons-material/Dashboard";
import ShoppingCartIcon from "@mui/icons-material/ShoppingCart";
import demoTheme from "@/theme/theme";
import { ThemeProvider } from "@mui/material/styles";
import { AppProvider } from "@toolpad/core/nextjs";
import logo from "@assets/Images/Logo.png";
const navigation = [
{
segment: "dashboard",
title: "Dashboard",
icon: <DashboardIcon />,
},
{
segment: "ground-manager",
title: "Ground Manager",
icon: <ShoppingCartIcon />,
children: [
{
segment: "view-grounds",
title: "View Grounds",
icon: <ShoppingCartIcon />,
},
],
},
{
segment: "banner-manager",
title: "Banner Manager",
icon: <ShoppingCartIcon />,
children: [
{
segment: "add-banners",
title: "Add New Banner",
icon: <ShoppingCartIcon />,
},
{
segment: "view-banners",
title: "View All Banners",
icon: <ShoppingCartIcon />,
},
],
},
{
segment: "tournament-manager",
title: "Tournament Manager",
icon: <ShoppingCartIcon />,
children: [
{
segment: "add-tournament",
title: "Add Tournament",
icon: <ShoppingCartIcon />,
},
{
segment: "view-tournament",
title: "View Tournament",
icon: <ShoppingCartIcon />,
},
{
segment: "user-tournament/register",
title: "Registered User",
icon: <ShoppingCartIcon />,
},
],
},
{
segment: "user-manager",
title: "User Manager",
icon: <ShoppingCartIcon />,
children: [
{
segment: "ground-owners",
title: "View Ground Owner ",
icon: <ShoppingCartIcon />,
},
{
segment: "user-registered",
title: "View Users",
icon: <ShoppingCartIcon />,
},
],
},
{
segment: "support-manager",
title: "Support Manager",
icon: <ShoppingCartIcon />,
children: [
{
segment: "user-support",
title: "User Support",
icon: <ShoppingCartIcon />,
},
],
},
{
segment: "notification-manager",
title: "Notification Manager",
icon: <ShoppingCartIcon />,
children: [
{
segment: "push-notification",
title: "App Notification",
icon: <ShoppingCartIcon />,
},
],
},
];
const geistSans = localFont({
src: "./fonts/GeistVF.woff",
variable: "--font-geist-sans",
weight: "100 900",
});
const geistMono = localFont({
src: "./fonts/GeistMonoVF.woff",
variable: "--font-geist-mono",
weight: "100 900",
});
export const metadata = {
title: "asdasdas",
description: "adsasdasd",
};
export default function RootLayout({ children }) {
return (
<html lang="en">
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
<Provider>
<AppRouterCacheProvider>
<AppProvider
theme={demoTheme}
navigation={navigation}
branding={{
logo: <img src={logo} alt="logo" />,
title: "",
}}
>
{children}
</AppProvider>
</AppRouterCacheProvider>
</Provider>
</body>
</html>
);
} this is my code Here Provider is React Query ---> "use client";
import { QueryClientProvider,QueryClient } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { useState } from "react";
export default function Provider({children}){
const[queryClient] = useState(()=> new QueryClient({
defaultOptions:{
queries:{
staleTime:6*1000,
refetchInterval:6*1000,
cacheTime: 1000 * 60 * 60 * 24, //24 hourss...
},
}
}));
return(
<QueryClientProvider client={queryClient}>
<ReactQueryDevtools initialIsOpen={false} />
{children}
</QueryClientProvider>
)
} |
Try adding |
This should fix the problem for now, but before we close this issue let's try to find out why it is required to add |
MY updated Code in NextJS RootLayout.
|
Try changing the value of the attribute to |
@bharatkashyap
|
@bharatkashyap @aarongarciah @apedroferreira Hydration Error is not occured if i following this but it is mentioned different in dashboard layout. It is very confusing. |
Try to follow these docs: https://mui.com/toolpad/core/integrations/nextjs-approuter/ |
I cannot reproduce the error anymore - the hydration warning goes away even in the Sandbox you've provided on adding the I think it might not be very productive to have this discussion on a GitHub issue. @ashishjaswal2002 Please open a question on Stack Overflow with a reproduction link and we can hopefully find an answer there 👍🏻 |
color-scheme
hydration warnings
Let me following the article again if i didn't find the issue then i m closing by myself. |
It is working fine but there is one problem
|
Material Ui should add |
Closed |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note @ashishjaswal2002 How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
Search keywords:
Search keywords:
The text was updated successfully, but these errors were encountered: