insin / gatsby-plugin-dark-mode

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

Fixing unnecessary reflow bug in plugin #7

Closed siwalikm closed 4 years ago

siwalikm commented 4 years ago

If we set your theme as light/dark and reload the page, we won't see anything visually but you can really see this bug if you are doing any animation on your toggle switch based on theme value.

Simply console logging the theme value and triggering route change will show this - image which is causing the following visual glitch. image

Solution: Setting the default value of theme to window.__theme ~null~ will fix this issue coz if __theme value is not present, it would default to falsy value now.

If this looks file, I would also request you to do a new v1.1.1 release with this change.

siwalikm commented 4 years ago

Sorry, this doesn't make sense as window is not present while SSR hence prod build would fail. In my defence, I'm new to gatsby/react. Closing this.