Skip to content

Commit

Permalink
Merge pull request #316 from EpicsDAO/improve-doc
Browse files Browse the repository at this point in the history
fix mode refresh problem
  • Loading branch information
KishiTheMechanic authored Oct 17, 2024
2 parents b257265 + 00af7ec commit e9deaea
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { cn } from '@/lib/utils'
import { Link } from '@/navigation'
import { useLocale, useTranslations } from 'next-intl'
import Image from 'next/image'
import { useTheme } from 'next-themes'
import { useTheme } from '@/hooks/utils/useTheme'
import { faDiscord } from '@fortawesome/free-brands-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { DEFAULT_PATHS } from '../defaultNavs'
Expand Down Expand Up @@ -57,7 +57,8 @@ const logos = [
export default function HomeHeroRow() {
const t = useTranslations()
const locale = useLocale()
const { theme } = useTheme()
const { theme, mounted } = useTheme()
if (!mounted) return null

return (
<>
Expand Down
5 changes: 3 additions & 2 deletions website/solv-epics-dev/src/components/config/ModeToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import * as React from 'react'
import { MoonIcon, SunIcon } from '@radix-ui/react-icons'
import { useTheme } from 'next-themes'
import { useTheme } from '@/hooks/utils/useTheme'

import { Button } from '@/components/ui/button'
import {
Expand All @@ -14,8 +14,9 @@ import {
import { useTranslations } from 'next-intl'

export function ModeToggle() {
const { setTheme } = useTheme()
const t = useTranslations()
const { theme, mounted, setTheme } = useTheme()
if (!mounted) return null

return (
<DropdownMenu>
Expand Down
14 changes: 14 additions & 0 deletions website/solv-epics-dev/src/hooks/utils/useTheme.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use client'
import { useTheme as useNextTheme } from 'next-themes'
import { useEffect, useState } from 'react'

export function useTheme() {
const [mounted, setMounted] = useState(false)
const { theme, setTheme } = useNextTheme()

useEffect(() => {
setMounted(true)
}, [])

return { theme, setTheme, mounted }
}

0 comments on commit e9deaea

Please sign in to comment.