Skip to content

Commit 33d2090

Browse files
YOEL311YoelNaki
authored andcommitted
check observers is not nullish before access
to work with v5 of react query
1 parent 799efff commit 33d2090

File tree

1 file changed

+2
-2
lines changed
  • packages/flipper-plugin-react-query-native-devtools/src/utils

1 file changed

+2
-2
lines changed

packages/flipper-plugin-react-query-native-devtools/src/utils/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ export function formatTimestamp(timestamp: number): string {
1919
export function getObserversCounter(query: Query): number {
2020
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2121
/* @ts-ignore */
22-
return query.observers.length;
22+
return query.observers?.length ?? 0;
2323
}
2424

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

3131
export function makeQuerySelectionKey(query: Query): string {

0 commit comments

Comments
 (0)