chore(ui): shadcn bileşenleri, use-mobile ve ESLint ayarı
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { useSyncExternalStore } from "react";
|
||||
|
||||
const MOBILE_BREAKPOINT = 768;
|
||||
const QUERY = `(max-width: ${MOBILE_BREAKPOINT - 1}px)`;
|
||||
|
||||
function subscribe(onChange: () => void) {
|
||||
const mql = window.matchMedia(QUERY);
|
||||
mql.addEventListener("change", onChange);
|
||||
return () => mql.removeEventListener("change", onChange);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ekran mobil genişlikte mi (< 768px)? Sunucuda ve hydration sırasında `false` döner,
|
||||
* ardından tarayıcı değerine geçer (effect içinde setState yok).
|
||||
*/
|
||||
export function useIsMobile() {
|
||||
return useSyncExternalStore(
|
||||
subscribe,
|
||||
() => window.matchMedia(QUERY).matches,
|
||||
() => false,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user