@cripty2001/utils 0.0.141 → 0.0.142
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.js +2 -6
- package/package.json +1 -1
package/dist/react-whispr.js
CHANGED
|
@@ -149,18 +149,14 @@ function useSynced(def, value, setValue) {
|
|
|
149
149
|
*/
|
|
150
150
|
function useAsync(f, data, debouce = 200) {
|
|
151
151
|
// Initing reactive input
|
|
152
|
-
const
|
|
153
|
-
if (!whisprRef.current) {
|
|
154
|
-
whisprRef.current = whispr_1.Whispr.create(data ?? (0, _1.getRandomId)());
|
|
155
|
-
}
|
|
156
|
-
const [input, setInput] = whisprRef.current;
|
|
152
|
+
const [input, setInput] = useSafeRef(() => whispr_1.Whispr.create(data ?? (0, _1.getRandomId)()));
|
|
157
153
|
if (data !== null) {
|
|
158
154
|
(0, react_1.useEffect)(() => {
|
|
159
155
|
setInput(data); // Debouncing already handled by dispatcher
|
|
160
156
|
}, [data, setInput]);
|
|
161
157
|
}
|
|
162
158
|
// Initing dispatcher
|
|
163
|
-
const dispatcher = (
|
|
159
|
+
const dispatcher = useSafeRef(() => new Dispatcher_1.Dispatcher(input, f, debouce));
|
|
164
160
|
// Returning dispatcher
|
|
165
161
|
return dispatcher;
|
|
166
162
|
}
|
package/package.json
CHANGED