Use performance.now instead of Date.now

This commit is contained in:
Koen Zweerts 2023-11-16 11:11:48 +01:00
parent 7d6fde2dea
commit 907e85493f
No known key found for this signature in database
GPG Key ID: 9A1C21BCCE1A150F

View File

@ -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;