File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change 1
- import React from 'react'
1
+ import React , { useMemo } from 'react'
2
2
import { QueryFunction } from '../core/types'
3
3
4
4
import { notifyManager } from '../core/notifyManager'
@@ -118,14 +118,20 @@ export function useQueries<T extends any[]>(
118
118
119
119
const queryClient = useQueryClient ( )
120
120
121
- const defaultedQueries = queries . map ( options => {
122
- const defaultedOptions = queryClient . defaultQueryObserverOptions ( options )
121
+ const defaultedQueries = useMemo (
122
+ ( ) =>
123
+ queries . map ( options => {
124
+ const defaultedOptions = queryClient . defaultQueryObserverOptions (
125
+ options
126
+ )
123
127
124
- // Make sure the results are already in fetching state before subscribing or updating options
125
- defaultedOptions . optimisticResults = true
128
+ // Make sure the results are already in fetching state before subscribing or updating options
129
+ defaultedOptions . optimisticResults = true
126
130
127
- return defaultedOptions
128
- } )
131
+ return defaultedOptions
132
+ } ) ,
133
+ [ queries , queryClient ]
134
+ )
129
135
130
136
const [ observer ] = React . useState (
131
137
( ) => new QueriesObserver ( queryClient , defaultedQueries )
You can’t perform that action at this time.
0 commit comments