mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2026-08-02 07:25:21 -04:00
actually listen to react-hooks/exhaustive-deps warning
This commit is contained in:
+9
-1
@@ -2,4 +2,12 @@ import { useContext } from "react";
|
||||
import { ThemeContext } from "../contexts/ThemeContext";
|
||||
|
||||
// convenience hook to get access to ThemeContext's state/functions from pages/components/etc.
|
||||
export const useTheme = () => useContext(ThemeContext);
|
||||
export const useTheme = () => {
|
||||
const context = useContext(ThemeContext);
|
||||
|
||||
if (!context) {
|
||||
throw new Error("useTheme must be used inside of a ThemeProvider.");
|
||||
}
|
||||
|
||||
return context;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user