fixed hydration error when changing theme and added dynamic default avatar

This commit is contained in:
Polaris
2024-07-24 23:25:01 -04:00
parent 8df0064100
commit 0a2eac63b6
7 changed files with 171 additions and 86 deletions

View File

@ -1,9 +1,23 @@
"use client";
import * as React from "react";
import { ThemeProvider as NextThemesProvider } from "next-themes";
import { type ThemeProviderProps } from "next-themes/dist/types";
import { ThemeProvider } from "next-themes";
import { useEffect, useState } from "react";
export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
return <NextThemesProvider {...props}>{children}</NextThemesProvider>;
function Providers({ children }: { children: React.ReactNode }) {
const [mounted, setMounted] = useState(false);
useEffect(() => {
setMounted(true);
}, []);
if (!mounted) {
return null;
}
return (
<ThemeProvider attribute="class" enableSystem={true}>
{children}
</ThemeProvider>
);
}
export default Providers;