Skip to content

Commit fcdc103

Browse files
committed
🔨 refactor: isTouchDevice util함수로 분리
1 parent 441daf9 commit fcdc103

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/hooks/useDetectInactivity.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useCallback, useEffect, useState } from 'react';
22
import useTimer from './useTimer';
33
import { Fn } from '../types';
4-
import { isClient, throttle } from '../utils';
4+
import { isTouchDevice, throttle } from '../utils';
55

66
/**
77
* 일정 시간(ms) 동안 활동이 없을 때 지정된 콜백 함수를 실행하는 훅.
@@ -65,10 +65,3 @@ const useDetectInactivity = (time: number, onInactivity: Fn) => {
6565
};
6666

6767
export default useDetectInactivity;
68-
69-
const isTouchDevice = () => {
70-
if (!isClient) {
71-
return false;
72-
}
73-
return 'ontouchstart' in window || navigator.maxTouchPoints > 0;
74-
};

src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export { delayExecution, type CancelToken } from './delayExecution';
22
export { throttle } from './throttle';
33
export { isClient } from './isClient';
4+
export { isTouchDevice } from './isTouchDevice';

src/utils/isTouchDevice.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { isClient } from './isClient';
2+
3+
export const isTouchDevice = () => {
4+
if (!isClient) {
5+
return false;
6+
}
7+
return 'ontouchstart' in window || navigator.maxTouchPoints > 0;
8+
};

0 commit comments

Comments
 (0)