código partido en src/: la app no cambia ni un byte
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YA7U5k2DMU8ZdD6MztyVYS
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
const { useState, useEffect, useCallback, useMemo, useRef } = React;
|
||||
|
||||
// Detecta pantalla estrecha (móvil) y se reajusta al rotar/redimensionar.
|
||||
// Reutilizable para adaptar cualquier vista a móvil sin media queries CSS.
|
||||
function useIsMobile(breakpoint) {
|
||||
const bp = breakpoint || 560;
|
||||
const [isMobile, setIsMobile] = useState(
|
||||
typeof window !== "undefined" ? window.innerWidth <= bp : false
|
||||
);
|
||||
useEffect(() => {
|
||||
const onResize = () => setIsMobile(window.innerWidth <= bp);
|
||||
window.addEventListener("resize", onResize);
|
||||
return () => window.removeEventListener("resize", onResize);
|
||||
}, [bp]);
|
||||
return isMobile;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user