Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ab9dfff33f |
17
parfum-shop/src/theme/ThemeContext.jsx
Normal file
17
parfum-shop/src/theme/ThemeContext.jsx
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { createContext, useContext } from "react";
|
||||||
|
|
||||||
|
const ThemeContext = createContext(null);
|
||||||
|
|
||||||
|
function ThemeProvider({ value, children }) {
|
||||||
|
return <ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>;
|
||||||
|
}
|
||||||
|
|
||||||
|
function useTheme() {
|
||||||
|
const context = useContext(ThemeContext);
|
||||||
|
if (!context) {
|
||||||
|
throw new Error("useTheme must be used within ThemeProvider.");
|
||||||
|
}
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { ThemeProvider, useTheme };
|
||||||
Loading…
x
Reference in New Issue
Block a user