From 9cd209dcfbc24037f3f574ff81ea6d8cd9f5bb48 Mon Sep 17 00:00:00 2001 From: Mostafa Shamsitabar Date: Sat, 3 Apr 2021 15:08:10 +0430 Subject: [PATCH] [:bug:] fixed an issue that caused problem with persisted states --- packages/sonnat-ui/src/styles/useDarkMode/useDarkMode.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sonnat-ui/src/styles/useDarkMode/useDarkMode.js b/packages/sonnat-ui/src/styles/useDarkMode/useDarkMode.js index 8a941d3..91349a4 100644 --- a/packages/sonnat-ui/src/styles/useDarkMode/useDarkMode.js +++ b/packages/sonnat-ui/src/styles/useDarkMode/useDarkMode.js @@ -4,11 +4,11 @@ import usePreviousValue from "../../utils/usePreviousValue"; import defaultTheme from "../defaultTheme"; export default function useDarkMode(isDarkMode = false, theme = defaultTheme) { - const prevState = usePreviousValue(isDarkMode); const cachedTheme = React.useRef(theme); + const prevState = usePreviousValue(isDarkMode); const newTheme = React.useMemo(() => { - if (prevState != null && isDarkMode !== prevState) { + if (isDarkMode !== prevState) { return { ...cachedTheme.current, colors: {