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

Calling SetTheme doesn't immediately update the background-color #206

Open
smithshelke opened this issue Aug 22, 2023 · 0 comments
Open

Comments

@smithshelke
Copy link

smithshelke commented Aug 22, 2023

Im trying to update theme-color meta tags after calling setTheme. However when i log the css background-color, it is still the older one.
for ex.

useEffect(() => {
  const bgColor =  getComputedStyle(document.body).getPropertyValue('background-color')
  console.log(bgColor) //white
},[theme])
setTheme('dark')

However when i do the same log from chrome developer console after i do setTheme('dark'), i get black.

So im assuming that this is some race condition. A solution could be to have a callback after the theme is set and the css classes are updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant