20 lines
525 B
TypeScript
20 lines
525 B
TypeScript
import { useContext } from "react";
|
|
|
|
import { MediaQueryContext, SelectedColorContext } from "./context";
|
|
|
|
export function useMediaQuery() {
|
|
const context = useContext(MediaQueryContext);
|
|
if (context === undefined) {
|
|
throw new Error("useMediaQuery must be used within a MediaQueryProvider");
|
|
}
|
|
return context;
|
|
}
|
|
|
|
export function useSelectedColor() {
|
|
const context = useContext(SelectedColorContext);
|
|
if (!context) {
|
|
throw new Error("useColor must be used within a ColorProvider");
|
|
}
|
|
return context;
|
|
}
|