mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 10:40:41 +01:00
fix(website): hydration issues due to rendering on the server of client-side logic
This commit is contained in:
@@ -11,11 +11,11 @@ export function usePageTitle(title: string) {
|
||||
}
|
||||
|
||||
export function useColorScheme() {
|
||||
if (typeof window === "undefined") return;
|
||||
|
||||
const [ prefersDark, setPrefersDark ] = useState((window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches));
|
||||
const defaultValue = (typeof window !== "undefined" && (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches));
|
||||
const [ prefersDark, setPrefersDark ] = useState(defaultValue);
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === "undefined") return;
|
||||
const mediaQueryList = window.matchMedia("(prefers-color-scheme: dark)");
|
||||
const listener = () => setPrefersDark((window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user