Skip to content

Commit dfe94ea

Browse files
Enhance data fetching in App component with incremental watch query
1 parent 7281525 commit dfe94ea

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/App.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,16 @@ function App() {
1313

1414
// Example of a watch query using useQuery hook
1515
// This demonstrates how to fetch and automatically update data when the underlying table changes
16+
// using an incremental watch query - see here https://docs.powersync.com/usage/use-case-examples/watch-queries#incremental-watch-queries
1617
const { data: counters, isLoading } = useQuery<CounterRecord>(
17-
`SELECT * FROM ${COUNTER_TABLE} ORDER BY created_at ASC`
18+
`SELECT * FROM ${COUNTER_TABLE} ORDER BY created_at ASC`,
19+
[],
20+
{
21+
rowComparator: {
22+
keyBy: (item) => item.id,
23+
compareBy: (item) => JSON.stringify(item)
24+
}
25+
}
1826
);
1927

2028
// Get the current authenticated user's ID from Supabase on component mount

0 commit comments

Comments
 (0)