We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e5d445e commit 4867d7bCopy full SHA for 4867d7b
index.js
@@ -1208,12 +1208,12 @@ export function useSet(values) {
1208
1209
export function useThrottle(value, interval = 500) {
1210
const [throttledValue, setThrottledValue] = React.useState(value);
1211
- const lastUpdated = React.useRef();
+ const lastUpdated = React.useRef(null);
1212
1213
React.useEffect(() => {
1214
const now = Date.now();
1215
1216
- if (now >= lastUpdated.current + interval) {
+ if (lastUpdated.current && now >= lastUpdated.current + interval) {
1217
lastUpdated.current = now;
1218
setThrottledValue(value);
1219
} else {
0 commit comments