Skip to content

Commit

Permalink
Fix useTheme initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbarbara committed Oct 8, 2024
1 parent f8d7348 commit 321462b
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/hooks/useTheme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ let storedTheme: Theme;
export function useTheme() {
const emotionTheme = useThemeEmotion();
const needsUpdate = !storedTheme || !deepEqual(storedEmotionTheme, emotionTheme);
const nextTheme = useRef<Theme>(emotionTheme);
const nextTheme = useRef<Theme>(storedTheme ?? emotionTheme);

if (needsUpdate) {
storedEmotionTheme = emotionTheme;
nextTheme.current = mergeTheme(emotionTheme);
storedTheme = nextTheme.current;
} else {
nextTheme.current = Object.keys(emotionTheme).length ? mergeTheme(emotionTheme) : storedTheme;
}

const { dataAttributeName } = nextTheme.current;
Expand Down

0 comments on commit 321462b

Please sign in to comment.