-
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.
RC #291 - Adding "useTimer" hook; Adding zoom in/out functionality to…
… FacetSlider component
- Loading branch information
1 parent
8465447
commit 92980ea
Showing
6 changed files
with
358 additions
and
24 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
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
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,24 @@ | ||
// @flow | ||
|
||
import { useCallback, useRef } from 'react'; | ||
|
||
const DEFAULT_TIMEOUT = 500; | ||
|
||
const useTimer = () => { | ||
const timer = useRef(); | ||
|
||
const clearTimer = useCallback(() => { | ||
clearTimeout(timer.current); | ||
}, []); | ||
|
||
const setTimer = useCallback((callback, delay = DEFAULT_TIMEOUT) => { | ||
timer.current = setTimeout(callback, delay); | ||
}, []); | ||
|
||
return { | ||
clearTimer, | ||
setTimer | ||
}; | ||
}; | ||
|
||
export default useTimer; |
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
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
Oops, something went wrong.