@tanstack/react-query 5.27.1 → 5.27.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-query",
3
- "version": "5.27.1",
3
+ "version": "5.27.3",
4
4
  "description": "Hooks for managing, caching and syncing asynchronous and remote data in React",
5
5
  "author": "tannerlinsley",
6
6
  "license": "MIT",
@@ -41,7 +41,7 @@
41
41
  "!build/codemods/**/__tests__"
42
42
  ],
43
43
  "dependencies": {
44
- "@tanstack/query-core": "5.27.1"
44
+ "@tanstack/query-core": "5.27.3"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/react": "^18.2.55",
@@ -1223,7 +1223,7 @@ describe('useQuery', () => {
1223
1223
  data: undefined,
1224
1224
  isFetching: false,
1225
1225
  isSuccess: false,
1226
- isStale: true,
1226
+ isStale: false,
1227
1227
  })
1228
1228
  })
1229
1229
 
@@ -1248,7 +1248,7 @@ describe('useQuery', () => {
1248
1248
  React.useEffect(() => {
1249
1249
  setActTimeout(() => {
1250
1250
  queryClient.invalidateQueries({ queryKey: key })
1251
- }, 20)
1251
+ }, 10)
1252
1252
  }, [])
1253
1253
 
1254
1254
  return null
@@ -1256,14 +1256,14 @@ describe('useQuery', () => {
1256
1256
 
1257
1257
  renderWithClient(queryClient, <Page />)
1258
1258
 
1259
- await sleep(100)
1259
+ await sleep(50)
1260
1260
 
1261
1261
  expect(states.length).toBe(1)
1262
1262
  expect(states[0]).toMatchObject({
1263
1263
  data: undefined,
1264
1264
  isFetching: false,
1265
1265
  isSuccess: false,
1266
- isStale: true,
1266
+ isStale: false,
1267
1267
  })
1268
1268
  })
1269
1269
 
@@ -2435,28 +2435,23 @@ describe('useQuery', () => {
2435
2435
  rendered.getByText('Second Status: success')
2436
2436
  })
2437
2437
 
2438
- it('should not override query configuration on render', async () => {
2438
+ it('should update query options', async () => {
2439
2439
  const key = queryKey()
2440
2440
 
2441
- const queryFn1 = async () => {
2441
+ const queryFn = async () => {
2442
2442
  await sleep(10)
2443
2443
  return 'data1'
2444
2444
  }
2445
2445
 
2446
- const queryFn2 = async () => {
2447
- await sleep(10)
2448
- return 'data2'
2449
- }
2450
-
2451
2446
  function Page() {
2452
- useQuery({ queryKey: key, queryFn: queryFn1 })
2453
- useQuery({ queryKey: key, queryFn: queryFn2 })
2447
+ useQuery({ queryKey: key, queryFn, retryDelay: 10 })
2448
+ useQuery({ queryKey: key, queryFn, retryDelay: 20 })
2454
2449
  return null
2455
2450
  }
2456
2451
 
2457
2452
  renderWithClient(queryClient, <Page />)
2458
2453
 
2459
- expect(queryCache.find({ queryKey: key })!.options.queryFn).toBe(queryFn1)
2454
+ expect(queryCache.find({ queryKey: key })!.options.retryDelay).toBe(20)
2460
2455
  })
2461
2456
 
2462
2457
  it('should batch re-renders', async () => {
@@ -3685,10 +3680,10 @@ describe('useQuery', () => {
3685
3680
  it('should reset failureCount on successful fetch', async () => {
3686
3681
  const key = queryKey()
3687
3682
 
3688
- function Page() {
3689
- let counter = 0
3683
+ let counter = 0
3690
3684
 
3691
- const query = useQuery<string, Error>({
3685
+ function Page() {
3686
+ const query = useQuery({
3692
3687
  queryKey: key,
3693
3688
  queryFn: async () => {
3694
3689
  if (counter < 2) {
@@ -3783,9 +3778,9 @@ describe('useQuery', () => {
3783
3778
  <div>
3784
3779
  <div>FetchStatus: {query.fetchStatus}</div>
3785
3780
  <h2>Data: {query.data || 'no data'}</h2>
3786
- {query.isStale ? (
3781
+ {shouldFetch ? null : (
3787
3782
  <button onClick={() => setShouldFetch(true)}>fetch</button>
3788
- ) : null}
3783
+ )}
3789
3784
  </div>
3790
3785
  )
3791
3786
  }
@@ -3956,7 +3951,8 @@ describe('useQuery', () => {
3956
3951
  expect(results.length).toBe(3)
3957
3952
  expect(results[0]).toMatchObject({ data: 'initial', isStale: true })
3958
3953
  expect(results[1]).toMatchObject({ data: 'fetched data', isStale: true })
3959
- expect(results[2]).toMatchObject({ data: 'fetched data', isStale: true })
3954
+ // disabled observers are not stale
3955
+ expect(results[2]).toMatchObject({ data: 'fetched data', isStale: false })
3960
3956
  })
3961
3957
 
3962
3958
  it('it should support enabled:false in query object syntax', async () => {
@@ -4891,14 +4887,14 @@ describe('useQuery', () => {
4891
4887
  isPending: true,
4892
4888
  isFetching: false,
4893
4889
  isSuccess: false,
4894
- isStale: true,
4890
+ isStale: false,
4895
4891
  })
4896
4892
  expect(states[1]).toMatchObject({
4897
4893
  data: undefined,
4898
4894
  isPending: true,
4899
4895
  isFetching: true,
4900
4896
  isSuccess: false,
4901
- isStale: true,
4897
+ isStale: false,
4902
4898
  })
4903
4899
  expect(states[2]).toMatchObject({
4904
4900
  data: 1,
@@ -4912,7 +4908,7 @@ describe('useQuery', () => {
4912
4908
  isPending: true,
4913
4909
  isFetching: false,
4914
4910
  isSuccess: false,
4915
- isStale: true,
4911
+ isStale: false,
4916
4912
  })
4917
4913
  })
4918
4914