actually listen to react-hooks/exhaustive-deps warning

This commit is contained in:
2022-04-21 18:10:03 -04:00
parent 008bb3213b
commit 831139c132
11 changed files with 206 additions and 22 deletions
+9 -1
View File
@@ -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;
};