xeoneux / next-dark-mode

🌑 Enable dark mode for Next.js apps
https://next-dark-mode.vercel.app
MIT License
218 stars 8 forks source link

Cannot use the hook with styled-components #7

Closed ghost closed 3 years ago

ghost commented 3 years ago

disclaimer: I'm new to next.

  const {
    autoModeActive,
    autoModeSupported,
    darkModeActive,
    switchToAutoMode,
    switchToDarkMode,
    switchToLightMode,
  } = darkMode

this works well in_app, but when I try to use this as hook in a component, I can't use the following functions:

const {
    switchToAutoMode,  // function - toggles the auto mode on
    switchToDarkMode,  // function - toggles the dark mode on
    switchToLightMode, // function - toggles the light mode on
  } = useDarkMode()
  console.log(useDarkMode())
xeoneux commented 3 years ago

Hi @tchret I saw that removing the provider stopped the functions from working. I have removed it in the new update, please try the example now, you can use the hooks normally. Thanks