Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] isDarkTheme from useThemeContext always returns false #2912

Closed
apsdehal opened this issue Jun 9, 2020 · 5 comments · Fixed by #2974
Closed

[bug] isDarkTheme from useThemeContext always returns false #2912

apsdehal opened this issue Jun 9, 2020 · 5 comments · Fixed by #2974
Labels
bug An error in the Docusaurus core causing instability or issues with its execution mlh Major League Hacking Fellowship

Comments

@apsdehal
Copy link

apsdehal commented Jun 9, 2020

🐛 Bug Report

In the default template for docusaurus, I am trying to use theme context to get isDarkTheme's value. It is always set to false, even when I change to dark theme and then reload.

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

(Write your steps here:)

  1. Use `const {isDarkTheme} = useThemeContext()
  2. add console.log for isDarkTheme
  3. turn on dark theme and reload

Expected behavior

Should provide true when dark theme is set

Actual Behavior

isDarkTheme is false even when dark them is on

Your Environment

  • Docusaurus version used:2.0.0-alpha.56
  • Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Node version: v12.17.0
  • Operating system and version (desktop or mobile): Ubuntu 16.04
@apsdehal apsdehal added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jun 9, 2020
@yangshun yangshun added mlh Major League Hacking Fellowship and removed status: needs triage This issue has not been triaged by maintainers labels Jun 10, 2020
@SamChou19815
Copy link
Contributor

See #2646. It might be caused by the same issue.

@apsdehal
Copy link
Author

@SamChou19815 Thanks a lot. This does fix the issue. Maybe it needs to be documented better.

@slorber
Copy link
Collaborator

slorber commented Jun 10, 2020

I suggest we move to a non-default themeContext value + a clear error message to tell the user what he did wrong. Could link to an issue.

image

@JoelMarcey
Copy link
Contributor

@apsdehal Willing to submit a PR with better docs? 😊

@slorber
Copy link
Collaborator

slorber commented Jun 15, 2020

docs has been updated here by @Drewbi : #2934

still think it would be cool if the code did actually warn the user in case of using the hook without a provider (could throw with a link to the docs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution mlh Major League Hacking Fellowship
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants