insin / gatsby-plugin-dark-mode

A Gatsby plugin which handles some of the details of implementing a dark mode theme
MIT License
68 stars 19 forks source link

TypeError: window.__setPreferredTheme is not a function #2

Open kiku511 opened 5 years ago

kiku511 commented 5 years ago

Steps to reproduce:

  1. gatsby new gatsby-blog
  2. npm install gatsby-plugin-dark-mode
  3. Copied the ThemeToggler code from documentation.
  4. Added Component to index.js
  5. Clicking on the generated checkbox produces error.
kiku511 commented 5 years ago

File:

toggleTheme node_modules/gatsby-plugin-dark-mode/ThemeToggler.js:54

SleeplessByte commented 5 years ago

Did you forget to include the plugin in your gatsby-config.js?

SpacemanPete commented 5 years ago

I got the same error. Restarting my local dev server fixed it for me.

ethernal commented 4 years ago

Sadly I have the same issue:

  1. restarted dev server,
  2. removed options from plugin initialization,
  3. cleared cache and started server again.

Still the same, crashes when clicking the checkbox.

twanmulder commented 4 years ago

I had the same error, but it was fixed by adding "--save" to the npm command. So to install the plugin, I used:

npm install gatsby-plugin-dark-mode --save
muhammedMoussa commented 4 years ago

Did you forget to include the plugin in your gatsby-config.js?

yeah, this works fine.