mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-07-11 22:44:47 +00:00
fix useTouchDevice
This commit is contained in:
parent
c380893040
commit
da4cc5f451
22 changed files with 23 additions and 23 deletions
|
|
@ -7,7 +7,7 @@ const query = "(pointer: coarse)";
|
|||
const getServerSnapshot = () => null;
|
||||
|
||||
export function useTouchDevice() {
|
||||
const queryRef = useRef<ReturnType<typeof window.matchMedia>>(null);
|
||||
const queryRef = useRef<null | ReturnType<typeof window.matchMedia>>(null);
|
||||
|
||||
const subscribe = useCallback((onStoreChange: () => void) => {
|
||||
const mql = window.matchMedia(query);
|
||||
|
|
@ -19,7 +19,7 @@ export function useTouchDevice() {
|
|||
}, []);
|
||||
|
||||
const getSnapshot = useCallback(() => {
|
||||
return queryRef.current.matches;
|
||||
return queryRef.current?.matches ?? null;
|
||||
}, []);
|
||||
|
||||
const isTouch = useSyncExternalStore<boolean | null>(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue