Skip to content

Commit

Permalink
Merge pull request #2652 from anstapol/use-live-query-deps
Browse files Browse the repository at this point in the history
fix: forwaring dependencies within useLiveQuery
  • Loading branch information
AndriiSherman authored Aug 5, 2024
2 parents 7fb8dfa + bb3017f commit 73674df
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drizzle-orm/src/expo-sqlite/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { SQLiteRelationalQuery } from '~/sqlite-core/query-builders/query.ts';

export const useLiveQuery = <T extends Pick<AnySQLiteSelect, '_' | 'then'> | SQLiteRelationalQuery<'sync', unknown>>(
query: T,
deps: unknown[] = [],
) => {
const [data, setData] = useState<Awaited<T>>(
(is(query, SQLiteRelationalQuery) && query.mode === 'first' ? undefined : []) as Awaited<T>,
Expand Down Expand Up @@ -43,7 +44,7 @@ export const useLiveQuery = <T extends Pick<AnySQLiteSelect, '_' | 'then'> | SQL
return () => {
listener?.remove();
};
}, []);
}, deps);

return {
data,
Expand Down

0 comments on commit 73674df

Please sign in to comment.