@reactuses/core 5.0.16 → 5.0.18
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/README.md +8 -8
- package/dist/{index-client-DSNqfa2q.cjs → index-client-DJgtg2U_.cjs} +4 -3
- package/dist/{index-client-KksAIxbB.js → index-client-Qon46B4S.js} +4 -3
- package/dist/index.cjs +379 -340
- package/dist/index.d.cts +141 -98
- package/dist/index.d.mts +141 -98
- package/dist/index.d.ts +141 -98
- package/dist/index.mjs +379 -342
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -30,19 +30,19 @@ Collection of essential React Hooks Utilities.
|
|
|
30
30
|
## QuickStart
|
|
31
31
|
|
|
32
32
|
```tsx harmony
|
|
33
|
-
import { useToggle } from
|
|
33
|
+
import { useToggle } from '@reactuses/core'
|
|
34
34
|
|
|
35
35
|
function Demo() {
|
|
36
|
-
const [on, toggle] = useToggle(true)
|
|
36
|
+
const [on, toggle] = useToggle(true)
|
|
37
37
|
|
|
38
38
|
return (
|
|
39
39
|
<div>
|
|
40
|
-
<div>{on ?
|
|
40
|
+
<div>{on ? 'ON' : 'OFF'}</div>
|
|
41
41
|
<button onClick={toggle}>Toggle</button>
|
|
42
42
|
<button onClick={() => toggle(true)}>set ON</button>
|
|
43
43
|
<button onClick={() => toggle(false)}>set OFF</button>
|
|
44
44
|
</div>
|
|
45
|
-
)
|
|
45
|
+
)
|
|
46
46
|
}
|
|
47
47
|
```
|
|
48
48
|
|
|
@@ -52,7 +52,7 @@ Refer to [documentations](https://reactuse.com/) for more details.
|
|
|
52
52
|
|
|
53
53
|
## Documentation & Live Examples
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
- [Documentation](https://reactuse.com/)
|
|
56
56
|
|
|
57
57
|
<hr/>
|
|
58
58
|
|
|
@@ -89,8 +89,8 @@ See the [**ChangeLog**](https://github.com/childrentime/reactuse/blob/main/packa
|
|
|
89
89
|
|
|
90
90
|
This project is heavily inspired by the following awesome projects.
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
- [streamich/react-use](https://github.com/streamich/react-use)
|
|
93
|
+
- [ahooks](https://github.com/alibaba/hooks)
|
|
94
|
+
- [vueuse](https://github.com/vueuse/vueuse)
|
|
95
95
|
|
|
96
96
|
<hr/>
|
|
@@ -3,7 +3,7 @@ var React = require('react');
|
|
|
3
3
|
|
|
4
4
|
function assignRef(ref, value) {
|
|
5
5
|
if (ref == null) return;
|
|
6
|
-
if (typeof ref ===
|
|
6
|
+
if (typeof ref === 'function') {
|
|
7
7
|
ref(value);
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
@@ -20,9 +20,10 @@ function mergeRefs(...refs) {
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
function useMergedRefs(...refs) {
|
|
24
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
25
|
return React.useMemo(()=>mergeRefs(...refs), refs);
|
|
25
|
-
}
|
|
26
|
+
}
|
|
26
27
|
|
|
27
28
|
exports.assignRef = assignRef;
|
|
28
29
|
exports.mergeRefs = mergeRefs;
|
|
@@ -3,7 +3,7 @@ import { useMemo } from 'react';
|
|
|
3
3
|
|
|
4
4
|
function assignRef(ref, value) {
|
|
5
5
|
if (ref == null) return;
|
|
6
|
-
if (typeof ref ===
|
|
6
|
+
if (typeof ref === 'function') {
|
|
7
7
|
ref(value);
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
@@ -20,8 +20,9 @@ function mergeRefs(...refs) {
|
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
function useMergedRefs(...refs) {
|
|
24
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
25
|
return useMemo(()=>mergeRefs(...refs), refs);
|
|
25
|
-
}
|
|
26
|
+
}
|
|
26
27
|
|
|
27
28
|
export { assignRef as a, mergeRefs as m, useMergedRefs as u };
|