@cripty2001/utils 0.0.142 → 0.0.143
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/react-whispr.d.ts +1 -1
- package/dist/react-whispr.js +3 -5
- package/package.json +1 -1
package/dist/react-whispr.d.ts
CHANGED
|
@@ -80,7 +80,7 @@ export declare function useRelTime(refresh?: number): (ts: Date | number) => str
|
|
|
80
80
|
*/
|
|
81
81
|
export declare function useSearcher<T>(data: SearcherData<T>[], q: string): SearcherData<T>[];
|
|
82
82
|
/**
|
|
83
|
-
* A react ref hook with safe
|
|
83
|
+
* A react ref hook with safe lazy initialization, ready for safe side effects.
|
|
84
84
|
* @remarks The initialization function will only be called once, and the result will be stored in the ref.
|
|
85
85
|
* @param value The value to initialize the ref with. If a function is provided, it will be called to initialize the ref.
|
|
86
86
|
* @returns
|
package/dist/react-whispr.js
CHANGED
|
@@ -232,17 +232,15 @@ function useSearcher(data, q) {
|
|
|
232
232
|
return useWhisprValue(searcher);
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
235
|
-
* A react ref hook with safe
|
|
235
|
+
* A react ref hook with safe lazy initialization, ready for safe side effects.
|
|
236
236
|
* @remarks The initialization function will only be called once, and the result will be stored in the ref.
|
|
237
237
|
* @param value The value to initialize the ref with. If a function is provided, it will be called to initialize the ref.
|
|
238
238
|
* @returns
|
|
239
239
|
*/
|
|
240
240
|
function useSafeRef(value) {
|
|
241
241
|
const ref = (0, react_1.useRef)(null);
|
|
242
|
-
(
|
|
243
|
-
if (ref.current !== null)
|
|
244
|
-
return;
|
|
242
|
+
if (ref.current === null) {
|
|
245
243
|
ref.current = value();
|
|
246
|
-
}
|
|
244
|
+
}
|
|
247
245
|
return ref.current;
|
|
248
246
|
}
|
package/package.json
CHANGED