()
| 3 | import { useSyncExternalStore } from 'react'; |
| 4 | |
| 5 | export const useIsMobile = () => { |
| 6 | const query = `(max-width: ${MOBILE_BREAKPOINT - 1}px)`; |
| 7 | return useSyncExternalStore( |
| 8 | (callback) => { |
| 9 | const mql = window.matchMedia(query); |
| 10 | mql.addEventListener('change', callback); |
| 11 | return () => mql.removeEventListener('change', callback); |
| 12 | }, |
| 13 | () => window.matchMedia(query).matches, |
| 14 | () => false, |
| 15 | ); |
| 16 | }; |
no outgoing calls
no test coverage detected