Skip to content

Commit

Permalink
feat: change theme in useEffect
Browse files Browse the repository at this point in the history
I hate hooks
  • Loading branch information
Yazawazi committed May 24, 2024
1 parent bfb5dfc commit 51869f1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/GiscusComment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import Giscus from "@giscus/react"
import { useEffect, useRef, useState } from "react"

const GiscusComment = () => {
const [theme, setTheme] = useState(document.documentElement.getAttribute('data-theme'))
const [theme, setTheme] = useState('preferred_color_scheme')
const observerLock = useRef(false)

const updateTheme = () => {
setTheme(document.documentElement.getAttribute('data-theme'))
}

useEffect(() => {
setTheme(document.documentElement.getAttribute('data-theme'))
if (!observerLock.current) {
observerLock.current = true
const observer = new MutationObserver(() => {
Expand Down

0 comments on commit 51869f1

Please sign in to comment.