TanStackT
TanStack5w ago
1 reply
brilliant-lime

Do collections need to be provided to the deps array of useLiveQuery()?

Let's say the collection based to the live query hook can change.
For this example, we have a hook that returns a todos collection based on a namespace.

Until now, I'm explicitely putting the collection in the deps array. Can you confirm this is needed?

const todosCollection = useTodosCollection(namespace);
const query = useLiveQuery((query) => query.from({ todos: todosCollection }), [todosCollection]);


ps: I haven't fully migrated to new on-demand collections, that's my I still maintain the a collections store
Was this page helpful?