File tree Expand file tree Collapse file tree 2 files changed +24
-6
lines changed
react-query/src/__tests__ Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -112,11 +112,7 @@ export class QueriesObserver<
112112 ( observer , index ) => observer !== prevObservers [ index ] ,
113113 )
114114
115- if (
116- prevObservers . length === newObservers . length &&
117- ! hasIndexChange &&
118- newObservers . length > 0
119- ) {
115+ if ( prevObservers . length === newObservers . length && ! hasIndexChange ) {
120116 return
121117 }
122118
Original file line number Diff line number Diff line change @@ -978,7 +978,7 @@ describe('useQueries', () => {
978978 )
979979 } )
980980
981- it ( 'should not return new instances when called without queries' , async ( ) => {
981+ it . skip ( 'should not return new instances when called without queries' , async ( ) => {
982982 const key = queryKey ( )
983983 const ids : Array < number > = [ ]
984984 let resultChanged = 0
@@ -1027,6 +1027,28 @@ describe('useQueries', () => {
10271027 expect ( resultChanged ) . toBe ( 1 )
10281028 } )
10291029
1030+ it ( 'should not have infinite render loops with empty queries (#6645)' , async ( ) => {
1031+ let renderCount = 0
1032+
1033+ function Page ( ) {
1034+ const result = useQueries ( {
1035+ queries : [ ] ,
1036+ } )
1037+
1038+ React . useEffect ( ( ) => {
1039+ renderCount ++
1040+ } )
1041+
1042+ return < div > data: { JSON . stringify ( result ) } </ div >
1043+ }
1044+
1045+ renderWithClient ( queryClient , < Page /> )
1046+
1047+ await sleep ( 10 )
1048+
1049+ expect ( renderCount ) . toBe ( 1 )
1050+ } )
1051+
10301052 it ( 'should only call combine with query results' , async ( ) => {
10311053 const key1 = queryKey ( )
10321054 const key2 = queryKey ( )
You can’t perform that action at this time.
0 commit comments