From c6436358500f8c71233279a99f166af6dd8e4196 Mon Sep 17 00:00:00 2001 From: Dominik Dorfmeister Date: Sat, 2 Nov 2024 17:42:03 +0000 Subject: [PATCH] fix(useQueries): warn on duplicate keys (#8246) --- packages/query-core/src/queriesObserver.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/query-core/src/queriesObserver.ts b/packages/query-core/src/queriesObserver.ts index a15139d24e..ea0ca7b02a 100644 --- a/packages/query-core/src/queriesObserver.ts +++ b/packages/query-core/src/queriesObserver.ts @@ -91,6 +91,15 @@ export class QueriesObserver< this.#queries = queries this.#options = options + if (process.env.NODE_ENV !== 'production') { + const queryHashes = queries.map((query) => query.queryHash) + if (new Set(queryHashes).size !== queryHashes.length) { + console.warn( + '[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior.', + ) + } + } + notifyManager.batch(() => { const prevObservers = this.#observers