@pylonsync/react 0.3.321 → 0.3.323
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 +3 -3
- package/src/hooks.ts +7 -1
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.3.
|
|
6
|
+
"version": "0.3.323",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./src/index.ts",
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"prepack": "bun run build"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@pylonsync/sdk": "0.3.
|
|
17
|
-
"@pylonsync/sync": "0.3.
|
|
16
|
+
"@pylonsync/sdk": "0.3.323",
|
|
17
|
+
"@pylonsync/sync": "0.3.323"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"react": ">=19.0.0"
|
package/src/hooks.ts
CHANGED
|
@@ -44,6 +44,12 @@ export interface UseQueryOneReturn<T> {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
// ---------------------------------------------------------------------------
|
|
47
|
+
// A single shared empty array reused as every useQuery's SSR snapshot. A fresh
|
|
48
|
+
// `[]` per call makes React's useSyncExternalStore warn "The result of
|
|
49
|
+
// getServerSnapshot should be cached to avoid an infinite loop", so hand it one
|
|
50
|
+
// stable reference.
|
|
51
|
+
const EMPTY_SNAPSHOT: readonly unknown[] = [];
|
|
52
|
+
|
|
47
53
|
// useQuery — high-level hook returning {data, loading, error}
|
|
48
54
|
// ---------------------------------------------------------------------------
|
|
49
55
|
|
|
@@ -127,7 +133,7 @@ export function useQuery<T = Row>(
|
|
|
127
133
|
return snapshotCache.current.rows;
|
|
128
134
|
}, [sync, entity, optionsKey, options]);
|
|
129
135
|
|
|
130
|
-
const getServerSnapshot = useCallback((): T[] =>
|
|
136
|
+
const getServerSnapshot = useCallback((): T[] => EMPTY_SNAPSHOT as T[], []);
|
|
131
137
|
|
|
132
138
|
const data = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
133
139
|
|