From b02d3d98e8d37dc2bfdc1f886993b99761bb24bf Mon Sep 17 00:00:00 2001 From: DefectingCat Date: Sun, 25 Jun 2023 14:59:22 +0800 Subject: [PATCH] fix hydration error --- components/post/post-commnet-line.tsx | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/components/post/post-commnet-line.tsx b/components/post/post-commnet-line.tsx index 28f7e20..f38d880 100644 --- a/components/post/post-commnet-line.tsx +++ b/components/post/post-commnet-line.tsx @@ -1,5 +1,6 @@ 'use client'; +import useMounted from 'lib/hooks/use-mounted'; import { useTheme } from 'next-themes'; import Image from 'next/image'; import { memo } from 'react'; @@ -8,16 +9,27 @@ const PostCommnetLine = () => { const { systemTheme, theme } = useTheme(); const currentTheme = theme === 'system' ? systemTheme : theme; + const { mounted } = useMounted(); + return ( <>
- {currentTheme === 'dark' ? ( - + {mounted ? ( + currentTheme === 'dark' ? ( + + ) : ( + + ) ) : (