@aiszlab/relax 1.0.10 → 1.0.11

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/dist/index.d.ts CHANGED
@@ -3,3 +3,4 @@ export { useDebounceCallback } from './use-debounce-callback';
3
3
  export { useImageLoader } from './use-image-loader';
4
4
  export { useMount } from './use-mount';
5
5
  export { useMounted } from './use-mounted';
6
+ export { useTimeout } from './use-timeout';
package/dist/index.js CHANGED
@@ -3,3 +3,4 @@ export { useDebounceCallback } from './use-debounce-callback.js';
3
3
  export { useImageLoader } from './use-image-loader.js';
4
4
  export { useMount } from './use-mount.js';
5
5
  export { useMounted } from './use-mounted.js';
6
+ export { useTimeout } from './use-timeout.js';
@@ -0,0 +1,21 @@
1
+ import { useRef, useEffect } from 'react';
2
+
3
+ /**
4
+ * @author murukal
5
+ *
6
+ * @description
7
+ * timeout effect
8
+ */
9
+ const useTimeout = (handler, { duration }) => {
10
+ const timer = useRef(null);
11
+ useEffect(() => {
12
+ timer.current = setTimeout(handler, duration);
13
+ return () => {
14
+ if (!timer.current)
15
+ return;
16
+ clearTimeout(timer.current);
17
+ };
18
+ }, [duration]);
19
+ };
20
+
21
+ export { useTimeout };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiszlab/relax",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "react utils collection",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -8,7 +8,7 @@
8
8
  "dev": "rollup -c -w",
9
9
  "build": "rollup -c",
10
10
  "clean:build": "rm -rf dist && rm -rf typings",
11
- "prepatch": "npm run clean:build && npm run build && npm version prepatch && npm publish"
11
+ "pub": "npm run clean:build && npm run build && npm publish"
12
12
  },
13
13
  "dependencies": {
14
14
  "rxjs": "^7.8.1"