Skip to content

Commit

Permalink
check observers is not mulish before access
Browse files Browse the repository at this point in the history
to work with v5 of react query
  • Loading branch information
YOEL311 authored Oct 31, 2023
1 parent 799efff commit 4a91714
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ export function formatTimestamp(timestamp: number): string {
export function getObserversCounter(query: Query): number {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
/* @ts-ignore */
return query.observers.length;
return query.observers?.length ?? 0;
}

export function isQueryActive(query: Query): boolean {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
/* @ts-ignore */
return query.observers.some((observer) => observer.options.enabled !== false);
return query.observers?.some((observer) => observer.options.enabled !== false) ?? false;
}

export function makeQuerySelectionKey(query: Query): string {
Expand Down

0 comments on commit 4a91714

Please sign in to comment.