daphnis/app/theme-provider.tsx
2024-07-24 23:26:57 -04:00

24 lines
555 B
TypeScript

"use client";
// https://github.com/pacocoursey/next-themes/issues/169#issuecomment-1539498884
import { ThemeProvider } from "next-themes";
import { useEffect, useState } from "react";
function CustomThemeProvider({ 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 CustomThemeProvider;