After migration to chakra v1 useColorMode hook does not seem to work properly in production
See original GitHub issueRef: https://github.com/NeonLaw/codebase/issues/776
useColorMode
hook does not seem to work properly i.e on the initial render the border colour which is applied using it does not work i.e the desired border-color
is not being applied to the Sections as shown below in the screenshot
same is true for the other elements
Once the theme is switched via the Theme Switcher the useColorMode
hook seems to work as expected.
To Reproduce
visit: https://neonlaw.com
Note: Locally the useColorMode
hook seems to work fine.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Color Mode - Chakra UI
useColorMode is a React hook that gives you access to the current color mode, and a function to toggle the color mode. Toggle...
Read more >Upgrading to v1 - Chakra UI
Here's a list of steps to migrate your project to v1. Don't worry if your styles aren't exactly the same, this is to...
Read more >Chakra UI color mode changes on page refresh, because of ...
getItem('chakra-ui-color-mode') so create theme.js file ... mounts with 1.5 seconds delay, I noticed it doesn't work without some delay.
Read more >How to add dark mode toggle to Next.js application using ...
Chakra exposes hook useColorMode function which will allow us to change the color mode as preferred. Note: Please run yarn add @chakra-ui/icons ...
Read more >Quick and easy forms! I'm migrating from Chakra UI to AWS ...
repo: https://github.com/mtliendo/serverless-contact-form-with-sendgrid-playgrounddocs: https://ui.docs.amplify.aws.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t use this functionality yet but I may do in the future so I want to add my two cents. The “fix” they did seems to have been to remove the Content Security Policy which is a terrible solution to this issue. Not being able to have a strict CSP will be a deal-breaker for many people (me included). I actually found this thread because of some inline styling that my CSP blocked which meant I had no styling anymore. I don’t have time right now to dig into that and formulate an issue, but it definitely looks like a problem (maybe with Emotion though). Chakra is such an awesome project and I know you work hard and can’t solve everything. I just wanted to point out that inline styles and scripts should not be added lightly and especially not without having a workaround (if they really have to be inline I guess a hash has to be used, I don’t think a nonce will work with statically generated pages).
This should be reopened. There seems to be no workaround if one wants strict CSP.