From a413b808655dc6e833b6e55dc17361fe77caf3b4 Mon Sep 17 00:00:00 2001 From: ahmadgaz Date: Tue, 1 Oct 2024 23:40:03 -0700 Subject: [PATCH] check if isClient for other parts of component --- .../molecules/client/color-mode-picker/component.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/molecules/client/color-mode-picker/component.tsx b/components/molecules/client/color-mode-picker/component.tsx index 6068445..1f464e0 100644 --- a/components/molecules/client/color-mode-picker/component.tsx +++ b/components/molecules/client/color-mode-picker/component.tsx @@ -21,6 +21,9 @@ const ColorModePickerWithoutCookies: React.FC = () => { setTheme(localStorage.theme); }, []); React.useEffect(() => { + if (!isClient) { + return; + } if (theme) { localStorage.theme = theme; } else { @@ -37,11 +40,14 @@ const ColorModePickerWithoutCookies: React.FC = () => { document.documentElement.classList.remove('dark'); setCookie('theme', 'light', { path: '/' }); } - }, [theme, setCookie]); + }, [theme, isClient, setCookie]); function handleChange(e: React.ChangeEvent) { const theme = e.target.value; setTheme(theme); } + if (!isClient) { + return null; + } return (