Answers for "toggle dark mode react using 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 "Swift"

Browse Popular Code Answers by Language