···
1
1
'use client';
2
2
3
3
-
import { useTheme } from '@/lib/theme-context';
3
3
+
import { useTheme, ThemeContextType, Theme } from '@/lib/theme-context';
4
4
import React, { useState, useEffect } from 'react';
5
5
import styles from './ThemeToggle.module.css';
6
6
···
38
38
export default function ThemeToggle() {
39
39
// Prevent hydration errors by using conditional hooks
40
40
const [mounted, setMounted] = useState(false);
41
41
-
const [themeState, setThemeState] = useState('system');
41
41
+
const [themeState, setThemeState] = useState<Theme>('system');
42
42
43
43
// Safe way to access theme context that won't break SSR
44
44
-
let themeContext;
44
44
+
let themeContext: ThemeContextType | undefined = undefined;
45
45
try {
46
46
themeContext = useTheme();
47
47
} catch (e) {
···
2
2
3
3
import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react';
4
4
5
5
-
type Theme = 'light' | 'dark' | 'system';
5
5
+
export type Theme = 'light' | 'dark' | 'system';
6
6
7
7
-
interface ThemeContextType {
7
7
+
export interface ThemeContextType {
8
8
theme: Theme;
9
9
setTheme: (theme: Theme) => void;
10
10
}