Skip to content

Commit 937c1e2

Browse files
fix tests
1 parent 0b8f9ae commit 937c1e2

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

packages/react/src/hooks/suspense/useWatchedSuspenseQuery.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export const useWatchedSuspenseQuery = <T = any>(
3434
return {
3535
...result,
3636
// The result above is readonly, but this API expects a mutable array
37-
data: [...result.data]
37+
// We need to keep the same reference also.
38+
data: result.data as T[]
3839
};
3940
};

packages/react/src/hooks/watched/useWatchedQuery.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ export const useWatchedQuery = <RowType = unknown>(
4444
const result = useWatchedQuerySubscription(watchedQuery);
4545
return {
4646
...result,
47-
// The Watched Query API returns readonly arrays,
47+
// The Watched Query API returns readonly arrays.
48+
// We need to keep the same reference also.
4849
// This allows compatibility with the hook API.
49-
data: [...result.data]
50+
data: result.data as RowType[]
5051
};
5152
};

packages/vue/src/composables/useWatchedQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export const useWatchedQuery = <T = any>(
7373
isLoading.value = state.isLoading;
7474
isFetching.value = state.isFetching;
7575
// The watched query state is readonly
76-
data.value = [...state.data];
76+
data.value = state.data as T[];
7777
if (state.error) {
7878
const wrappedError = new Error('PowerSync failed to fetch data: ' + state.error.message);
7979
wrappedError.cause = state.error;

0 commit comments

Comments
 (0)