Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
1 line
1.3 KiB
Plaintext
1 line
1.3 KiB
Plaintext
{"version":3,"file":"useThrottledValue.js","names":["useEffect","useState","useThrottledValue","value","delay","throttledValue","setThrottledValue","handler","setTimeout","clearTimeout"],"sources":["../../src/hooks/useThrottledValue.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n\n/**\n * A custom React hook to throttle a value so that it updates no more than once every `delay` milliseconds.\n * @param {any} value - The value to be throttled.\n * @param {number} delay - The minimum delay (in milliseconds) between updates.\n * @returns {any} - The throttled value.\n */\nexport function useThrottledValue(value, delay) {\n const [throttledValue, setThrottledValue] = useState(value)\n\n useEffect(() => {\n const handler = setTimeout(() => {\n setThrottledValue(value)\n }, delay)\n\n // Cleanup the timeout if the value changes before the delay is completed\n return () => {\n clearTimeout(handler)\n }\n }, [value, delay])\n\n return throttledValue\n}\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ;AAEpC;;;;;;AAMA,OAAO,SAASC,kBAAkBC,KAAK,EAAEC,KAAK;EAC5C,MAAM,CAACC,cAAA,EAAgBC,iBAAA,CAAkB,GAAGL,QAAA,CAASE,KAAA;EAErDH,SAAA,CAAU;IACR,MAAMO,OAAA,GAAUC,UAAA,CAAW;MACzBF,iBAAA,CAAkBH,KAAA;IACpB,GAAGC,KAAA;IAEH;IACA,OAAO;MACLK,YAAA,CAAaF,OAAA;IACf;EACF,GAAG,CAACJ,KAAA,EAAOC,KAAA,CAAM;EAEjB,OAAOC,cAAA;AACT","ignoreList":[]} |