@fibery/react 2.0.4 → 2.0.6
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/lib/use-previous.d.ts +6 -1
- package/lib/use-previous.js +12 -1
- package/package.json +2 -2
package/lib/use-previous.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
//#region src/use-previous.d.ts
|
|
2
2
|
declare function usePrevious<T>(value: T): T | null;
|
|
3
|
+
/**
|
|
4
|
+
* Like {@link usePrevious}, but on the first render it returns the current value
|
|
5
|
+
* instead of `null` — for effects that only want to react to actual changes.
|
|
6
|
+
*/
|
|
7
|
+
declare function usePreviousValue<T>(value: T): T;
|
|
3
8
|
//#endregion
|
|
4
|
-
export { usePrevious };
|
|
9
|
+
export { usePrevious, usePreviousValue };
|
package/lib/use-previous.js
CHANGED
|
@@ -7,5 +7,16 @@ function usePrevious(value) {
|
|
|
7
7
|
}, [value]);
|
|
8
8
|
return ref.current;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Like {@link usePrevious}, but on the first render it returns the current value
|
|
12
|
+
* instead of `null` — for effects that only want to react to actual changes.
|
|
13
|
+
*/
|
|
14
|
+
function usePreviousValue(value) {
|
|
15
|
+
const ref = useRef(value);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
ref.current = value;
|
|
18
|
+
}, [value]);
|
|
19
|
+
return ref.current;
|
|
20
|
+
}
|
|
10
21
|
//#endregion
|
|
11
|
-
export { usePrevious };
|
|
22
|
+
export { usePrevious, usePreviousValue };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/react",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@tanstack/react-query": "5.102.8",
|
|
23
|
-
"@fibery/helpers": "
|
|
23
|
+
"@fibery/helpers": "4.1.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": "18.3.1",
|