Docusaurus: Dark theme blinks on refresh

Created on 14 Nov 2019  路  3Comments  路  Source: facebook/docusaurus

馃悰 Bug Report

When loading a page with dark mode turned on, a light theme is visible for a while before the previously selected dark theme is applied.

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

  1. Select dark theme in navbar
  2. Reload (F5 or Ctrl + R) any page

Expected behavior

A dark theme should be shown right away

Actual Behavior

For a second or so, a "regular" light theme is showed, and only then a dark theme:

AwesomeScreenshot-2019-11-14-1573758888334

bug v2

Most helpful comment

Try reading this https://github.com/donavon/use-dark-mode/blob/develop/README.md#that-flash

To fix this, we need a setbody hooks to inject script into html body. So that it wont wait till React load to actually enter dark mode

All 3 comments

Yeah we're aware of this issue. It's because the theme is only applied after page load, that's why we see the flash. It's a little annoying but possible to fix - gatsbyjs.org doesn't have this issue.

A good example where there is no such issue - https://overreacted.io/ (yeah, powered by Gatsby).

Try reading this https://github.com/donavon/use-dark-mode/blob/develop/README.md#that-flash

To fix this, we need a setbody hooks to inject script into html body. So that it wont wait till React load to actually enter dark mode

Was this page helpful?
0 / 5 - 0 ratings