@lemon-fe/hooks 0.1.142 → 0.1.146

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.
@@ -0,0 +1,3 @@
1
+ import { useEffect } from 'react';
2
+ declare const useUpdateEffect: typeof useEffect;
3
+ export default useUpdateEffect;
@@ -0,0 +1,18 @@
1
+ import { useEffect, useRef } from 'react';
2
+ var useUpdateEffect = function useUpdateEffect(effect, deps) {
3
+ var isMounted = useRef(false);
4
+ // for react-refresh react 18
5
+ useEffect(function () {
6
+ return function () {
7
+ isMounted.current = false;
8
+ };
9
+ }, []);
10
+ useEffect(function () {
11
+ if (!isMounted.current) {
12
+ isMounted.current = true;
13
+ } else {
14
+ return effect();
15
+ }
16
+ }, deps);
17
+ };
18
+ export default useUpdateEffect;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/hooks",
3
- "version": "0.1.142",
3
+ "version": "0.1.146",
4
4
  "description": "> TODO: description",
5
5
  "author": "鲁盛杰 <lusj@cnlemon.net>",
6
6
  "homepage": "",
@@ -25,5 +25,6 @@
25
25
  "devDependencies": {
26
26
  "@types/color-string": "^1.5.2",
27
27
  "react": "^17.0.2"
28
- }
28
+ },
29
+ "gitHead": "88632b58b09887447b008f24b5a59610aaf8e551"
29
30
  }