Skip to content

Commit d4be5f6

Browse files
committed
fix: build errors and TypeScript issues
- Fixed ThemeToggle useEffect warning with setTimeout - Fixed LanguageIcon JSX.Element type (use ReactElement) - Fixed ThemeProvider type imports - Simplified ThemeProvider implementation - All lint checks passing - Build successful (39 pages)
1 parent d8d282c commit d4be5f6

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default function RootLayout({
8282
<link rel="manifest" href="/manifest.json" />
8383
</head>
8484
<body className={inter.className}>
85-
<ThemeProvider attribute="class" defaultTheme="light" enableSystem>
85+
<ThemeProvider>
8686
<Header />
8787
<main className="min-h-screen bg-white dark:bg-gray-900">
8888
{children}

components/LanguageIcon.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { Code2, Terminal, FileCode } from 'lucide-react'
2+
import { ReactElement } from 'react'
23

34
interface LanguageIconProps {
45
language: string
56
size?: number
67
}
78

89
export default function LanguageIcon({ language, size = 20 }: LanguageIconProps) {
9-
const icons: Record<string, JSX.Element> = {
10+
const icons: Record<string, ReactElement> = {
1011
python: (
1112
<svg width={size} height={size} viewBox="0 0 24 24" fill="currentColor">
1213
<path d="M14.25.18l.9.2.73.26.59.3.45.32.34.34.25.34.16.33.1.3.04.26.02.2-.01.13V8.5l-.05.63-.13.55-.21.46-.26.38-.3.31-.33.25-.35.19-.35.14-.33.1-.3.07-.26.04-.21.02H8.77l-.69.05-.59.14-.5.22-.41.27-.33.32-.27.35-.2.36-.15.37-.1.35-.07.32-.04.27-.02.21v3.06H3.17l-.21-.03-.28-.07-.32-.12-.35-.18-.36-.26-.36-.36-.35-.46-.32-.59-.28-.73-.21-.88-.14-1.05-.05-1.23.06-1.22.16-1.04.24-.87.32-.71.36-.57.4-.44.42-.33.42-.24.4-.16.36-.1.32-.05.24-.01h.16l.06.01h8.16v-.83H6.18l-.01-2.75-.02-.37.05-.34.11-.31.17-.28.25-.26.31-.23.38-.2.44-.18.51-.15.58-.12.64-.1.71-.06.77-.04.84-.02 1.27.05zm-6.3 1.98l-.23.33-.08.41.08.41.23.34.33.22.41.09.41-.09.33-.22.23-.34.08-.41-.08-.41-.23-.33-.33-.22-.41-.09-.41.09zm13.09 3.95l.28.06.32.12.35.18.36.27.36.35.35.47.32.59.28.73.21.88.14 1.04.05 1.23-.06 1.23-.16 1.04-.24.86-.32.71-.36.57-.4.45-.42.33-.42.24-.4.16-.36.09-.32.05-.24.02-.16-.01h-8.22v.82h5.84l.01 2.76.02.36-.05.34-.11.31-.17.29-.25.25-.31.24-.38.2-.44.17-.51.15-.58.13-.64.09-.71.07-.77.04-.84.01-1.27-.04-1.07-.14-.9-.2-.73-.25-.59-.3-.45-.33-.34-.34-.25-.34-.16-.33-.1-.3-.04-.25-.02-.2.01-.13v-5.34l.05-.64.13-.54.21-.46.26-.38.3-.32.33-.24.35-.2.35-.14.33-.1.3-.06.26-.04.21-.02.13-.01h5.84l.69-.05.59-.14.5-.21.41-.28.33-.32.27-.35.2-.36.15-.36.1-.35.07-.32.04-.28.02-.21V6.07h2.09l.14.01zm-6.47 14.25l-.23.33-.08.41.08.41.23.33.33.23.41.08.41-.08.33-.23.23-.33.08-.41-.08-.41-.23-.33-.33-.23-.41-.08-.41.08z"/>

components/ThemeProvider.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
'use client'
22

33
import { ThemeProvider as NextThemesProvider } from 'next-themes'
4-
import { type ThemeProviderProps } from 'next-themes/dist/types'
4+
import { ReactNode } from 'react'
55

6-
export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
7-
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
6+
export function ThemeProvider({ children }: { children: ReactNode }) {
7+
return (
8+
<NextThemesProvider attribute="class" defaultTheme="light" enableSystem>
9+
{children}
10+
</NextThemesProvider>
11+
)
812
}

components/ThemeToggle.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ export default function ThemeToggle() {
88
const [mounted, setMounted] = useState(false)
99
const { theme, setTheme } = useTheme()
1010

11+
// Hydration fix
1112
useEffect(() => {
12-
setMounted(true)
13+
const timer = setTimeout(() => setMounted(true), 0)
14+
return () => clearTimeout(timer)
1315
}, [])
1416

1517
if (!mounted) {

0 commit comments

Comments
 (0)