Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Fix issue with server build.

Mike Cao5f41447158d3
diff --git a/hooks/useTheme.js b/hooks/useTheme.js
index 46114d436..1231e2838 100644
--- a/hooks/useTheme.js
+++ b/hooks/useTheme.js
@@ -5,7 +5,12 @@ import { THEME_CONFIG } from 'lib/constants';
import { useEffect } from 'react';
export default function useTheme() {
- const defaultTheme = window?.matchMedia('prefers-color-scheme: dark')?.matches ? 'dark' : 'light';
+ const defaultTheme =
+ typeof window !== undefined
+ ? window?.matchMedia('prefers-color-scheme: dark')?.matches
+ ? 'dark'
+ : 'light'
+ : 'light';
const theme = useSelector(state => state.app.theme || getItem(THEME_CONFIG) || defaultTheme);
const dispatch = useDispatch();