You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .changeset/nine-pens-ring.md
+10-7Lines changed: 10 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,16 @@
2
2
'@powersync/vue': minor
3
3
---
4
4
5
-
- Added the ability to limit re-renders by specifying a `comparator` for query results. The `useQuery` hook will only emit `data` changes when the data has changed.
5
+
[Potentially breaking change] The `useQuery` hook results are now explicitly defined as readonly. These values should not be mutated.
6
+
7
+
- Added the ability to limit re-renders by specifying a `differentiator` for query results. The `useQuery` hook will only emit `data` changes when the data has changed.
6
8
7
9
```javascript
8
-
useQuery('SELECT * FROM lists WHERE name = ?', ['todo'], {
9
-
// This will be used to compare result sets between internal queries
10
-
comparator:newArrayComparator({
11
-
compareBy: (item) =>JSON.stringify(item)
12
-
})
13
-
}),
10
+
// The data here will maintain previous object references for unchanged items.
11
+
const { data } =useQuery('SELECT * FROM lists WHERE name = ?', ['aname'], {
Copy file name to clipboardExpand all lines: .changeset/swift-guests-explain.md
+8-7Lines changed: 8 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,14 @@
2
2
'@powersync/react': minor
3
3
---
4
4
5
-
- Added the ability to limit re-renders by specifying a `comparator` for query results. The `useQuery` hook will only emit `data` changes when the data has changed.
5
+
- Added the ability to limit re-renders by specifying a `differentiator` for query results. The `useQuery` hook will only emit `data` changes when the data has changed.
6
6
7
7
```javascript
8
-
useQuery('SELECT * FROM lists WHERE name = ?', ['todo'], {
9
-
// This will be used to compare result sets between internal queries
10
-
comparator:newArrayComparator({
11
-
compareBy: (item) =>JSON.stringify(item)
12
-
})
13
-
}),
8
+
// The data here will maintain previous object references for unchanged items.
9
+
const { data } =useQuery('SELECT * FROM lists WHERE name = ?', ['aname'], {
* Indicates the initial loading state (hard loading). Loading becomes false once the first set of results from the watched query is available or an error occurs.
@@ -25,3 +28,20 @@ export type QueryResult<RowType> = {
25
28
*/
26
29
refresh?: (signal?: AbortSignal)=>Promise<void>;
27
30
};
31
+
32
+
exporttypeQueryResult<RowType>={
33
+
data: RowType[];
34
+
/**
35
+
* Indicates the initial loading state (hard loading). Loading becomes false once the first set of results from the watched query is available or an error occurs.
36
+
*/
37
+
isLoading: boolean;
38
+
/**
39
+
* Indicates whether the query is currently fetching data, is true during the initial load and any time when the query is re-evaluating (useful for large queries).
0 commit comments