Answers for "dark mode with react hooks"

0

dark mode with react hooks

// DarkMode/index.js

const DarkModeToggle = () => {
  const [isDark, setIsDark] = useState(localStorage.getItem("theme") === "dark" ? true : false);
  useEffect(() => {
    document
    .getElementsByTagName("HTML")[0]
    .setAttribute("data-theme", localStorage.getItem("theme"));
  },[]);
Posted by: Guest on October-31-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language