Skip to content

Commit

Permalink
fixed the useMemo, useState
Browse files Browse the repository at this point in the history
  • Loading branch information
gbowne1 committed Mar 4, 2024
1 parent e76dbcd commit b5029d2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/client/src/context/themeContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ const ColorModeContext = React.createContext({ toggleColorMode: () => {} });

const ThemeProvider = ({ children }) => {
const prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
const [mode, setMode] = React.useState(
const [mode, setMode] = useState(
localStorage.getItem("mode") || (prefersDarkMode ? "dark" : "light")
);

useEffect(() => {
localStorage.setItem("mode", mode);
}, [mode]);

const colorMode = React.useMemo(
const colorMode = useMemo(
() => ({
toggleColorMode: () => {
setMode((prevMode) => {
Expand Down

0 comments on commit b5029d2

Please sign in to comment.