daphnis/app/theme-provider.tsx

24 lines
555 B
TypeScript
Raw Normal View History

2024-07-01 18:19:20 +00:00
"use client";
2024-07-25 03:26:57 +00:00
// https://github.com/pacocoursey/next-themes/issues/169#issuecomment-1539498884
import { ThemeProvider } from "next-themes";
import { useEffect, useState } from "react";
2024-07-01 18:19:20 +00:00
2024-07-25 03:26:57 +00:00
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>
);
2024-07-01 18:19:20 +00:00
}
2024-07-25 03:26:57 +00:00
export default CustomThemeProvider;