File tree 1 file changed +21
-0
lines changed
packages/react-query/src/__tests__
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -6211,4 +6211,25 @@ describe('useQuery', () => {
6211
6211
await waitFor ( ( ) => rendered . getByText ( 'Rendered Id: 2' ) )
6212
6212
expect ( spy ) . toHaveBeenCalledTimes ( 1 )
6213
6213
} )
6214
+ it ( 'should not cause an infinite render loop when using unstable callback ref' , async ( ) => {
6215
+ const key = queryKey ( )
6216
+
6217
+ function Test ( ) {
6218
+ const [ _ , setRef ] = React . useState < HTMLDivElement | null > ( )
6219
+
6220
+ const { data } = useQuery ( {
6221
+ queryKey : [ key ] ,
6222
+ queryFn : async ( ) => {
6223
+ await sleep ( 5 )
6224
+ return 'Works'
6225
+ } ,
6226
+ } )
6227
+
6228
+ return < div ref = { ( value ) => setRef ( value ) } > { data } </ div >
6229
+ }
6230
+
6231
+ const rendered = renderWithClient ( queryClient , < Test /> )
6232
+
6233
+ await waitFor ( ( ) => rendered . getByText ( 'Works' ) )
6234
+ } )
6214
6235
} )
You can’t perform that action at this time.
0 commit comments