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'
22import { QueryFunction } from '../core/types'
33
44import { notifyManager } from '../core/notifyManager'
@@ -118,14 +118,20 @@ export function useQueries<T extends any[]>(
118118
119119 const queryClient = useQueryClient ( )
120120
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+ )
123127
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
126130
127- return defaultedOptions
128- } )
131+ return defaultedOptions
132+ } ) ,
133+ [ queries , queryClient ]
134+ )
129135
130136 const [ observer ] = React . useState (
131137 ( ) => new QueriesObserver ( queryClient , defaultedQueries )
You can’t perform that action at this time.
0 commit comments