-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7495e25
commit 2557610
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { useEffect, useState } from "react"; | ||
/** | ||
* 시간을 인자로 받아 해당 시간이 지난 후 true를 리턴, 시간이 지나지 않았을 경우 false를 리턴 | ||
* @param time ms 단위, 기본값은 200ms | ||
* @returns 입력받은 시간이 지났는지 여부 | ||
*/ | ||
const useSkeletonTimer = (time: number = 200) => { | ||
const [isTimePassed, setTimer] = useState(false); | ||
|
||
useEffect(() => { | ||
const timerId = setTimeout(() => { | ||
setTimer(true); | ||
}, time); | ||
return () => { | ||
clearTimeout(timerId); | ||
}; | ||
}, []); | ||
return isTimePassed; | ||
}; | ||
|
||
export default useSkeletonTimer; |