Skip to content

Commit f934c18

Browse files
committed
Less initial page loading flashiness
1 parent e859715 commit f934c18

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

data-browser/src/components/SideBar/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ export function SideBar(): JSX.Element {
1919
const { drive, sideBarLocked, setSideBarLocked } = useSettings();
2020
const [ref, hoveringOverSideBar] = useHover<HTMLElement>(sideBarLocked);
2121
// Check if the window is small enough to hide the sidebar
22-
const isWideScreen = useMediaQuery(`(min-width: ${SIDEBAR_TOGGLE_WIDTH}px)`);
22+
const isWideScreen = useMediaQuery(
23+
`(min-width: ${SIDEBAR_TOGGLE_WIDTH}px)`,
24+
true,
25+
);
2326

2427
const { size, targetRef, dragAreaRef, isDragging } = useResizable(
2528
300,

data-browser/src/hooks/useMediaQuery.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { useEffect, useState } from 'react';
22

33
/** Watches a media query and returns a statefull result. */
4-
export function useMediaQuery(query: string): boolean {
5-
const [matches, setMatches] = useState(false);
4+
export function useMediaQuery(query: string, def = false): boolean {
5+
const [matches, setMatches] = useState(def);
66

77
useEffect(() => {
88
if (!window.matchMedia) {

0 commit comments

Comments
 (0)