Skip to content

Commit

Permalink
fix(useQueries): warn on duplicate keys (#8246)
Browse files Browse the repository at this point in the history
  • Loading branch information
TkDodo authored Nov 2, 2024
1 parent 39a35d8 commit c643635
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/query-core/src/queriesObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c643635

Please sign in to comment.