Skip to content

Commit

Permalink
optimization: detecting default os theme (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
prathameshbelurkar committed Jul 1, 2024
1 parent 58b5667 commit cd42ccb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/context/DarkModeContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { useLocalStorageState } from "../hooks/useLocalStorageState";
const DarkModeContext = createContext();

function DarkModeProvider({ children }) {
const [isDarkMode, setIsDarkMode] = useLocalStorageState(false, "isDarkMode");
const [isDarkMode, setIsDarkMode] = useLocalStorageState(
window.matchMedia("(prefers-color-scheme: dark)").matches,
"isDarkMode"
);

useEffect(
function () {
Expand Down

0 comments on commit cd42ccb

Please sign in to comment.