Merge pull request #4 from zweertsk/tweak/use-performance-now
Use performance.now instead of Date.now
This commit is contained in:
commit
a776ce53cb
@ -8,7 +8,7 @@ export function useThrottle(value: string, interval = 500) {
|
|||||||
const lastUpdated = React.useRef<number | null>(null);
|
const lastUpdated = React.useRef<number | null>(null);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const now = Date.now();
|
const now = performance.now();
|
||||||
|
|
||||||
if (!lastUpdated.current || now >= lastUpdated.current + interval) {
|
if (!lastUpdated.current || now >= lastUpdated.current + interval) {
|
||||||
lastUpdated.current = now;
|
lastUpdated.current = now;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user