mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 09:11:13 -05:00
Improve mobile detection logic to handle server-side rendering
Add a check for `window` existence in `useIsMobile` hook to prevent errors during SSR. Replit-Commit-Author: Agent Replit-Commit-Session-Id: f44f1d1b-1dd8-407b-8603-db12902e1a15 Replit-Commit-Checkpoint-Type: intermediate_checkpoint
This commit is contained in:
@@ -6,6 +6,8 @@ export function useIsMobile() {
|
||||
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (typeof window === 'undefined') return;
|
||||
|
||||
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
||||
const onChange = () => {
|
||||
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
||||
|
||||
Reference in New Issue
Block a user