question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

After migration to chakra v1 useColorMode hook does not seem to work properly in production

See original GitHub issue

Ref: 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

image

same is true for the other elements

image

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:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mattiaswcommented, Oct 3, 2020

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).

1reaction
afzaal-ameercommented, Jan 26, 2021

This should be reopened. There seems to be no workaround if one wants strict CSP.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found