-
Notifications
You must be signed in to change notification settings - Fork 151
Highlight component renders the wrong theme even though props are passed correctly #112
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
Comments
After messing with this for entirely too long I have found a solution--instead of attempting to utilize the "theme" prop, I instead simply created 2 CSS files--one for dark mode & one for light mode -- this allowed the code in prism-palenight-theme.css
prism-vslight-theme.css
|
I have the same issue. Doesn't toggle correctly between themes. |
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I am using Gatsby in combination with prism-react-renderer and I've come across an issue which is stumping me. I am attempting to avoid FOUC in prism-react-renderer when implementing a dark / light mode by injecting the
dark
class into my HTML before rendering the page via gatsby-ssr.js, like so:gatsby-ssr.js
While this all works fine for the page theme itself, the issues crop up with my CodeBlock rendering--as you can see in the code below, when I set the default theme I first check whether we have a
window
-- if we do, I check whether thedocument.documentElement.classList
contains our dark theme--if it does, we set this as the default theme. If ourwindow
is undefined, such as during the SSR, we simply return the light theme. This code works perfectly in development mode, and even appears to work perfectly when being served as a static bundle, unfortunately theHighlight
component renders the wrong theme even when receiving the correct props. Please see below:CodeBlock.tsx
As you can see below, the dark theme is correctly identified and rendered when running in development mode:
And even after building a production bundle and serving the dark theme is identified correctly, the correct props are passed, but the rendered HTML is incorrect--as you can see, the hex values on the theme are correct:
The props passed into the
Highlight
component are correct:Yet the HTML is incorrect and defaulting to the default light theme (and vice versa if I switch the default to dark):
You can access my repository with this code here:
https://github.com/cjones26/niggling-aspirations-blog/tree/738a7736e579e51dc7eb349b1404781e0007deef
Thanks!
The text was updated successfully, but these errors were encountered: