fix: import ThemeToggle directly, fix hydration error (#972)

support-auth-token
Meng Zhang 2023-12-07 14:11:40 +08:00 committed by GitHub
parent 452ab5c07a
commit 48340a775f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 7 deletions

View File

@ -4,7 +4,6 @@ import * as React from 'react'
import { cn } from '@/lib/utils'
import { buttonVariants } from '@/components/ui/button'
import { IconGitHub, IconNotice } from '@/components/ui/icons'
import dynamic from 'next/dynamic'
import Link from 'next/link'
import { useHealth } from '@/lib/hooks/use-health'
import { ReleaseInfo, useLatestRelease } from '@/lib/hooks/use-latest-release'
@ -12,11 +11,7 @@ import { compare } from 'compare-versions'
import { useWorkers } from '@/lib/hooks/use-workers'
import { WorkerKind } from '@/lib/gql/generates/graphql'
import { has } from 'lodash-es'
const ThemeToggle = dynamic(
() => import('@/components/theme-toggle').then(x => x.ThemeToggle),
{ ssr: false }
)
import { ThemeToggle } from './theme-toggle'
export function Header() {
const { data } = useHealth()

View File

@ -20,7 +20,7 @@ export function ThemeToggle() {
})
}}
>
{!theme ? null : theme === 'dark' ? (
{theme === 'dark' ? (
<IconMoon className="transition-all" />
) : (
<IconSun className="transition-all" />