@instantdb/react-common 0.22.96-experimental.add-posthog-frontend.20386914944.1 → 0.22.96

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instantdb/react-common",
3
- "version": "0.22.96-experimental.add-posthog-frontend.20386914944.1",
3
+ "version": "0.22.96",
4
4
  "description": "Instant DB shared components for React and React Native",
5
5
  "homepage": "https://github.com/instantdb/instant/tree/main/client/packages/react-common",
6
6
  "repository": {
@@ -53,8 +53,8 @@
53
53
  "react": ">=16"
54
54
  },
55
55
  "dependencies": {
56
- "@instantdb/core": "0.22.96-experimental.add-posthog-frontend.20386914944.1",
57
- "@instantdb/version": "0.22.96-experimental.add-posthog-frontend.20386914944.1"
56
+ "@instantdb/core": "0.22.96",
57
+ "@instantdb/version": "0.22.96"
58
58
  },
59
59
  "scripts": {
60
60
  "test": "vitest",
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import {
2
3
  // types
3
4
  Auth,
@@ -8,7 +9,6 @@ import {
8
9
  type ConnectionStatus,
9
10
  type TransactionChunk,
10
11
  type RoomSchemaShape,
11
- type InstaQLParams,
12
12
  type InstaQLOptions,
13
13
  type InstantConfig,
14
14
  type PageInfoResponse,
@@ -241,6 +241,10 @@ export default abstract class InstantReactAbstractDatabase<
241
241
  *
242
242
  */
243
243
  useAuth = (): AuthState => {
244
+ return this._useAuth();
245
+ };
246
+
247
+ protected _useAuth(): AuthState {
244
248
  // We use a ref to store the result of the query.
245
249
  // This is becuase `useSyncExternalStore` uses `Object.is`
246
250
  // to compare the previous and next state.
@@ -267,7 +271,7 @@ export default abstract class InstantReactAbstractDatabase<
267
271
  () => defaultAuthState,
268
272
  );
269
273
  return state;
270
- };
274
+ }
271
275
 
272
276
  /**
273
277
  * Subscribe to the currently logged in user.
package/src/useQuery.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import {
2
2
  weakHash,
3
3
  coerceQuery,
4
- type InstaQLParams,
5
4
  type InstaQLOptions,
6
- type InstantGraph,
7
5
  InstantCoreDatabase,
8
6
  InstaQLLifecycleState,
9
7
  InstantSchemaDef,
@@ -63,6 +61,10 @@ export function useQueryInternal<
63
61
  resultCacheRef.current = stateForResult(
64
62
  _core._reactor.getPreviousResult(query),
65
63
  );
64
+ // before the subscribeQuery is connected and calls it's own callback,
65
+ // we might have data in the store via SSR, we need to notify useSyncExternalStore that
66
+ // the data has changed.
67
+ cb();
66
68
 
67
69
  // Don't subscribe if query is null
68
70
  if (!query) {