budget-view-finance/src/hooks/use-mobile.tsx
gpt-engineer-app[bot] ff772429f7 Fix: Resolve import error in App.tsx
Fixes an import error in `App.tsx` related to the `authStore`.  The error message "Failed to resolve import "./stores/authStore" from "src/App.tsx". Does the file exist?" indicates that the specified module could not be found.  This commit addresses the issue by ensuring the correct import path or by creating the missing file.
2025-05-20 20:00:20 +00:00

24 lines
563 B
TypeScript

import { useState, useEffect } from 'react';
export function useIsMobile() {
const [isMobile, setIsMobile] = useState(false);
useEffect(() => {
const checkIfMobile = () => {
setIsMobile(window.innerWidth < 768);
};
// Verificar inicialmente
checkIfMobile();
// Adicionar listener para redimensionamento
window.addEventListener('resize', checkIfMobile);
// Limpar listener quando componente for desmontado
return () => window.removeEventListener('resize', checkIfMobile);
}, []);
return isMobile;
}