@powersync/react 1.7.1 → 1.7.3

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.
@@ -10,6 +10,12 @@ import { useNullableWatchedQuerySubscription } from './useWatchedQuerySubscripti
10
10
  */
11
11
  export const useWatchedQuery = (options) => {
12
12
  const { query, powerSync, queryChanged, options: hookOptions, active } = options;
13
+ // This ref is used to protect against cases where `queryChanged` changes multiple times too quickly to be
14
+ // picked up by the useEffect below. This typically happens when React.StrictMode is enabled.
15
+ const queryChangeRef = React.useRef(false);
16
+ if (queryChanged && !queryChangeRef.current) {
17
+ queryChangeRef.current = true;
18
+ }
13
19
  function createWatchedQuery() {
14
20
  if (!active) {
15
21
  return null;
@@ -34,13 +40,14 @@ export const useWatchedQuery = (options) => {
34
40
  // Indicates that the query will be re-fetched due to a change in the query.
35
41
  // Used when `isFetching` hasn't been set to true yet due to React execution.
36
42
  React.useEffect(() => {
37
- if (queryChanged) {
43
+ if (queryChangeRef.current) {
38
44
  watchedQuery?.updateSettings({
39
45
  query,
40
46
  throttleMs: hookOptions.throttleMs,
41
47
  reportFetching: hookOptions.reportFetching
42
48
  });
49
+ queryChangeRef.current = false;
43
50
  }
44
- }, [queryChanged]);
51
+ }, [queryChangeRef.current]);
45
52
  return useNullableWatchedQuerySubscription(watchedQuery);
46
53
  };
@@ -47,7 +47,7 @@ export const constructCompatibleQuery = (query, parameters = [], options) => {
47
47
  execute: () => query.execute()
48
48
  };
49
49
  }
50
- }, [query, powerSync]);
50
+ }, [query, powerSync, ...parameters]);
51
51
  const queryChanged = checkQueryChanged(parsedQuery, options);
52
52
  return {
53
53
  parsedQuery,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powersync/react",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "homepage": "https://docs.powersync.com",
26
26
  "peerDependencies": {
27
- "@powersync/common": "^1.37.0",
27
+ "@powersync/common": "^1.38.0",
28
28
  "react": "*"
29
29
  },
30
30
  "devDependencies": {
@@ -35,8 +35,9 @@
35
35
  "react": "18.3.1",
36
36
  "react-dom": "18.3.1",
37
37
  "react-error-boundary": "^4.1.0",
38
- "@powersync/common": "1.37.0",
39
- "@powersync/web": "1.26.0"
38
+ "@powersync/common": "1.38.0",
39
+ "@powersync/web": "1.26.1",
40
+ "@powersync/drizzle-driver": "0.5.0"
40
41
  },
41
42
  "scripts": {
42
43
  "build": "tsc -b",