- Initialize Next.js 14 web application with Material UI and TypeScript - Implement authentication (login/register) with device fingerprint - Create mobile-first responsive layout with app shell pattern - Add tracking pages for feeding, sleep, and diaper changes - Implement activity history with filtering - Configure backend CORS for web frontend (port 3030) - Update backend port to 3020, frontend to 3030 - Fix API response handling for auth endpoints 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
20 lines
509 B
TypeScript
20 lines
509 B
TypeScript
import { useState, useEffect } from 'react';
|
|
|
|
export const useMediaQuery = (query: string): boolean => {
|
|
const [matches, setMatches] = useState(false);
|
|
|
|
useEffect(() => {
|
|
const media = window.matchMedia(query);
|
|
if (media.matches !== matches) {
|
|
setMatches(media.matches);
|
|
}
|
|
|
|
const listener = () => setMatches(media.matches);
|
|
media.addEventListener('change', listener);
|
|
|
|
return () => media.removeEventListener('change', listener);
|
|
}, [matches, query]);
|
|
|
|
return matches;
|
|
};
|