@hrnec06/react_utils 1.3.4 → 1.3.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hrnec06/react_utils",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
4
4
  "description": "A debugger component for react.",
5
5
  "exports": {
6
6
  ".": "./src/index.ts"
@@ -0,0 +1,8 @@
1
+ import { useMemo, useRef } from "react";
2
+
3
+ export default function useEfficientRef<T>(callback: () => T): React.RefObject<T>
4
+ {
5
+ const defaultValue = useMemo(() => callback(), []);
6
+
7
+ return useRef<T>(defaultValue);
8
+ }
package/src/index.ts CHANGED
@@ -3,6 +3,9 @@ import useListener from "./hooks/useListener";
3
3
  import useUpdatedRef from "./hooks/useUpdatedRef";
4
4
  import useUpdateEffect from "./hooks/useUpdateEffect";
5
5
  import useWindowSize from "./hooks/useWindowSize";
6
+ import useEfficientRef from "./hooks/useEfficientRef";
7
+ import useEfficientState from "./hooks/useEfficientState";
8
+ import useUUID from "./hooks/useUUID";
6
9
 
7
10
  import useSignal, { Signal } from "./hooks/useSignal";
8
11
 
@@ -17,6 +20,9 @@ export {
17
20
  useUpdatedRef,
18
21
  useUpdateEffect,
19
22
  useWindowSize,
23
+ useEfficientRef,
24
+ useEfficientState,
25
+ useUUID,
20
26
 
21
27
  useSignal,
22
28
  Signal,