react-realtime-hooks 1.3.0 → 1.3.2
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/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useSyncExternalStore, useRef, useState, useEffect, useMemo,
|
|
1
|
+
import { useSyncExternalStore, useRef, useState, useEffect, useMemo, useInsertionEffect, useCallback } from 'react';
|
|
2
2
|
|
|
3
3
|
// src/hooks/useOnlineStatus.ts
|
|
4
4
|
|
|
@@ -444,7 +444,9 @@ var createReconnectAttempt = (attempt, trigger, options, lastDelayMs, config = {
|
|
|
444
444
|
};
|
|
445
445
|
var useStableCallback = (callback) => {
|
|
446
446
|
const callbackRef = useRef(callback);
|
|
447
|
-
|
|
447
|
+
useInsertionEffect(() => {
|
|
448
|
+
callbackRef.current = callback;
|
|
449
|
+
});
|
|
448
450
|
return useCallback((...args) => callbackRef.current(...args), []);
|
|
449
451
|
};
|
|
450
452
|
|
|
@@ -466,9 +468,7 @@ var useReconnect = (options = {}) => {
|
|
|
466
468
|
const commitState = (next) => {
|
|
467
469
|
const resolved = typeof next === "function" ? next(stateRef.current) : next;
|
|
468
470
|
stateRef.current = resolved;
|
|
469
|
-
|
|
470
|
-
setState(resolved);
|
|
471
|
-
});
|
|
471
|
+
setState(resolved);
|
|
472
472
|
};
|
|
473
473
|
const runAttempt = useStableCallback((attempt) => {
|
|
474
474
|
commitState({
|