Skip to content

Commit b58c4d3

Browse files
committed
refactor: fix lint problems
1 parent a9817f3 commit b58c4d3

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

apps/site/hooks/react-client/useMediaQuery.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@
33
import { useState, useEffect } from 'react';
44

55
const useMediaQuery = (query: string) => {
6-
const [matches, setMatches] = useState(false);
6+
const [matches, setMatches] = useState(() => {
7+
if (typeof window === 'undefined') {
8+
return false;
9+
}
10+
11+
return window.matchMedia?.(query)?.matches ?? false;
12+
});
713

814
useEffect(() => {
9-
const { matches, addEventListener, removeEventListener } =
10-
window.matchMedia?.(query) ?? {
11-
matches: false,
12-
addEventListener: () => {},
13-
removeEventListener: () => {},
14-
};
15-
16-
setMatches(matches);
15+
const { addEventListener, removeEventListener } = window.matchMedia?.(
16+
query
17+
) ?? {
18+
matches: false,
19+
addEventListener: () => {},
20+
removeEventListener: () => {},
21+
};
1722

1823
const handler = (event: MediaQueryListEvent) => setMatches(event.matches);
1924

apps/site/providers/navigationStateProvider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const NavigationStateProvider: FC<PropsWithChildren> = ({
1616
const navigationState = useRef<NavigationStateContextType>({});
1717

1818
return (
19+
// eslint-disable-next-line react-hooks/refs
1920
<NavigationStateContext.Provider value={navigationState.current}>
2021
{children}
2122
</NavigationStateContext.Provider>

0 commit comments

Comments
 (0)