@pylonsync/react 0.3.227 → 0.3.228

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/hooks.ts +16 -0
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.3.227",
6
+ "version": "0.3.228",
7
7
  "type": "module",
8
8
  "main": "src/index.ts",
9
9
  "types": "src/index.ts",
@@ -12,8 +12,8 @@
12
12
  "check": "tsc -p tsconfig.json --noEmit"
13
13
  },
14
14
  "dependencies": {
15
- "@pylonsync/sdk": "0.3.227",
16
- "@pylonsync/sync": "0.3.227"
15
+ "@pylonsync/sdk": "0.3.228",
16
+ "@pylonsync/sync": "0.3.228"
17
17
  },
18
18
  "peerDependencies": {
19
19
  "react": ">=19.0.0"
package/src/hooks.ts CHANGED
@@ -129,6 +129,16 @@ export function useQuery<T = Row>(
129
129
 
130
130
  const data = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
131
131
 
132
+ // Register interest so the reconcile safety net sweeps this entity
133
+ // even when the local replica has zero rows for it. Without this, a
134
+ // server row in a never-cached entity (created on another surface, a
135
+ // freshly-added entity) stays invisible until a full snapshot / cache
136
+ // clear. The first observe of an empty+hydrated entity also fires a
137
+ // one-shot fetch so it appears on mount. See SyncEngine.observeEntity.
138
+ useEffect(() => {
139
+ sync.observeEntity(entity);
140
+ }, [sync, entity]);
141
+
132
142
  const refetch = useCallback(() => {
133
143
  loading.current = true;
134
144
  error.current = null;
@@ -201,6 +211,12 @@ export function useQueryOne<T = Row>(
201
211
 
202
212
  const data = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
203
213
 
214
+ // Register interest so reconcile sweeps this entity even with zero
215
+ // local rows. See SyncEngine.observeEntity.
216
+ useEffect(() => {
217
+ sync.observeEntity(entity);
218
+ }, [sync, entity]);
219
+
204
220
  const refetch = useCallback(() => {
205
221
  loading.current = true;
206
222
  error.current = null;