Merge pull request #4 from zweertsk/tweak/use-performance-now

Use performance.now instead of Date.now
This commit is contained in:
Abi Raja 2023-11-16 08:16:24 -05:00 committed by GitHub
commit a776ce53cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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;