gatsby-plugin-dark-mode icon indicating copy to clipboard operation
gatsby-plugin-dark-mode copied to clipboard

TypeError: window.__setPreferredTheme is not a function

Open kiku511 opened this issue 5 years ago • 6 comments

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 avatar Mar 16 '19 05:03 kiku511

File:

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

kiku511 avatar Mar 16 '19 05:03 kiku511

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

SleeplessByte avatar Apr 15 '19 20:04 SleeplessByte

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

SpacemanPete avatar Jun 27 '19 20:06 SpacemanPete

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.

ethernal avatar Mar 17 '20 12:03 ethernal

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

twanmulder avatar May 03 '20 16:05 twanmulder

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

yeah, this works fine.

muhammedMoussa avatar Jun 05 '20 18:06 muhammedMoussa