type Theme = "light" | "dark";
type ThemeContextValue = {
theme: Theme;
setTheme: (t: Theme) => void;
};
const ThemeContext = React.createContext<ThemeContextValue | null>(null);
function useTheme(): ThemeContextValue {
const ctx = React.useContext(ThemeContext);
if (!ctx) throw new Error("ThemeProvider missing");
return ctx;
}
type Theme = "light" | "dark";
type ThemeContextValue = {
theme: Theme;
setTheme: (t: Theme) => void;
};
const ThemeContext = React.createContext<ThemeContextValue | null>(null);
function useTheme(): ThemeContextValue {
const ctx = React.useContext(ThemeContext);
if (!ctx) throw new Error("ThemeProvider missing");
return ctx;
}