@snack-uikit/utils 3.8.0 → 3.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 3.8.1 (2025-03-17)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **VMWDEV-2271:** fix timerId ([14fa135](https://github.com/cloud-ru-tech/snack-uikit/commit/14fa1351d12b76912b696aeaa6fcc7ce8d62d1b1))
12
+
13
+
14
+
15
+
16
+
6
17
  # 3.8.0 (2025-03-04)
7
18
 
8
19
 
@@ -15,13 +15,13 @@ const useEventHandler_1 = require("./useEventHandler");
15
15
  function useDebounce(callback) {
16
16
  let timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
17
17
  const timeStampRef = (0, react_1.useRef)(0);
18
- let timerId = -1;
18
+ const timerIdRef = (0, react_1.useRef)(-1);
19
19
  return (0, useEventHandler_1.useEventHandler)(() => {
20
20
  (0, utils_1.isBrowser)() && requestAnimationFrame(timestamp => {
21
21
  if (timestamp < timeStampRef.current) {
22
- clearTimeout(timerId);
22
+ clearTimeout(timerIdRef.current);
23
23
  }
24
- timerId = setTimeout(callback, timeout);
24
+ timerIdRef.current = setTimeout(callback, timeout);
25
25
  timeStampRef.current = timestamp + timeout;
26
26
  });
27
27
  });
@@ -8,14 +8,14 @@ import { useEventHandler } from './useEventHandler';
8
8
  */
9
9
  export function useDebounce(callback, timeout = 0) {
10
10
  const timeStampRef = useRef(0);
11
- let timerId = -1;
11
+ const timerIdRef = useRef(-1);
12
12
  return useEventHandler(() => {
13
13
  isBrowser() &&
14
14
  requestAnimationFrame(timestamp => {
15
15
  if (timestamp < timeStampRef.current) {
16
- clearTimeout(timerId);
16
+ clearTimeout(timerIdRef.current);
17
17
  }
18
- timerId = setTimeout(callback, timeout);
18
+ timerIdRef.current = setTimeout(callback, timeout);
19
19
  timeStampRef.current = timestamp + timeout;
20
20
  });
21
21
  });
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Utils",
7
- "version": "3.8.0",
7
+ "version": "3.8.1",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -39,5 +39,5 @@
39
39
  "react-swipeable": "7.0.2",
40
40
  "uncontrollable": "8.0.4"
41
41
  },
42
- "gitHead": "ec4e54b1ea5c4455ca404632e1f205e22b881f98"
42
+ "gitHead": "d12776ae6b32233f12df33facc32de6a8758706a"
43
43
  }
@@ -10,15 +10,15 @@ import { useEventHandler } from './useEventHandler';
10
10
  */
11
11
  export function useDebounce(callback: () => void, timeout = 0) {
12
12
  const timeStampRef = useRef<number>(0);
13
- let timerId: NodeJS.Timeout | number = -1;
13
+ const timerIdRef = useRef<NodeJS.Timeout | number>(-1);
14
14
 
15
15
  return useEventHandler(() => {
16
16
  isBrowser() &&
17
17
  requestAnimationFrame(timestamp => {
18
18
  if (timestamp < timeStampRef.current) {
19
- clearTimeout(timerId);
19
+ clearTimeout(timerIdRef.current);
20
20
  }
21
- timerId = setTimeout(callback, timeout);
21
+ timerIdRef.current = setTimeout(callback, timeout);
22
22
  timeStampRef.current = timestamp + timeout;
23
23
  });
24
24
  });