forked from hussiiii/Repcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuseDarkMode.js
More file actions
26 lines (18 loc) · 706 Bytes
/
useDarkMode.js
File metadata and controls
26 lines (18 loc) · 706 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// DEPRECATED: DOES NOT WORK ANYMORE
// import { useEffect, useState } from "react";
// function useDarkMode() {
// // Initialize theme from localStorage or default to 'dark'
// const [theme, setTheme] = useState(() => {
// return localStorage.getItem('theme') || 'dark';
// });
// const colorTheme = theme === "dark" ? "light" : "dark";
// useEffect(() => {
// const root = window.document.documentElement;
// root.classList.remove(colorTheme);
// root.classList.add(theme);
// // Save the current theme to localStorage
// localStorage.setItem("theme", theme);
// }, [theme, colorTheme]);
// return [colorTheme, setTheme];
// }
// export default useDarkMode;