@tanstack/react-query
Advanced tools
Comparing version
// src/suspense.ts | ||
var defaultThrowOnError = (_error, query) => query.state.data === void 0; | ||
var ensureSuspenseTimers = (defaultedOptions) => { | ||
const originalStaleTime = defaultedOptions.staleTime; | ||
if (defaultedOptions.suspense) { | ||
defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => Math.max(originalStaleTime(...args), 1e3) : Math.max(originalStaleTime ?? 1e3, 1e3); | ||
const clamp = (value) => value === "static" ? value : Math.max(value ?? 1e3, 1e3); | ||
const originalStaleTime = defaultedOptions.staleTime; | ||
defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => clamp(originalStaleTime(...args)) : clamp(originalStaleTime); | ||
if (typeof defaultedOptions.gcTime === "number") { | ||
@@ -8,0 +9,0 @@ defaultedOptions.gcTime = Math.max(defaultedOptions.gcTime, 1e3); |
// src/suspense.ts | ||
var defaultThrowOnError = (_error, query) => query.state.data === void 0; | ||
var ensureSuspenseTimers = (defaultedOptions) => { | ||
const originalStaleTime = defaultedOptions.staleTime; | ||
if (defaultedOptions.suspense) { | ||
defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => Math.max(originalStaleTime(...args), 1e3) : Math.max(originalStaleTime ?? 1e3, 1e3); | ||
const clamp = (value) => value === "static" ? value : Math.max(value ?? 1e3, 1e3); | ||
const originalStaleTime = defaultedOptions.staleTime; | ||
defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => clamp(originalStaleTime(...args)) : clamp(originalStaleTime); | ||
if (typeof defaultedOptions.gcTime === "number") { | ||
@@ -8,0 +9,0 @@ defaultedOptions.gcTime = Math.max(defaultedOptions.gcTime, 1e3); |
{ | ||
"name": "@tanstack/react-query", | ||
"version": "5.77.2", | ||
"version": "5.79.0", | ||
"description": "Hooks for managing, caching and syncing asynchronous and remote data in React", | ||
@@ -47,3 +47,3 @@ "author": "tannerlinsley", | ||
"dependencies": { | ||
"@tanstack/query-core": "5.77.2" | ||
"@tanstack/query-core": "5.79.0" | ||
}, | ||
@@ -56,3 +56,2 @@ "devDependencies": { | ||
"@vitejs/plugin-react": "^4.3.4", | ||
"eslint-plugin-react-compiler": "19.0.0-beta-df7b47d-20241124", | ||
"npm-run-all2": "^5.0.0", | ||
@@ -62,4 +61,4 @@ "react": "^19.0.0", | ||
"react-error-boundary": "^4.1.2", | ||
"@tanstack/query-test-utils": "0.0.0", | ||
"@tanstack/query-persist-client-core": "5.77.2" | ||
"@tanstack/query-persist-client-core": "5.79.0", | ||
"@tanstack/query-test-utils": "0.0.0" | ||
}, | ||
@@ -66,0 +65,0 @@ "peerDependencies": { |
@@ -24,11 +24,14 @@ import type { | ||
) => { | ||
const originalStaleTime = defaultedOptions.staleTime | ||
if (defaultedOptions.suspense) { | ||
// Handle staleTime to ensure minimum 1000ms in Suspense mode | ||
// This prevents unnecessary refetching when components remount after suspending | ||
const clamp = (value: number | 'static' | undefined) => | ||
value === 'static' ? value : Math.max(value ?? 1000, 1000) | ||
const originalStaleTime = defaultedOptions.staleTime | ||
defaultedOptions.staleTime = | ||
typeof originalStaleTime === 'function' | ||
? (...args) => Math.max(originalStaleTime(...args), 1000) | ||
: Math.max(originalStaleTime ?? 1000, 1000) | ||
? (...args) => clamp(originalStaleTime(...args)) | ||
: clamp(originalStaleTime) | ||
@@ -35,0 +38,0 @@ if (typeof defaultedOptions.gcTime === 'number') { |
@@ -1,3 +0,1 @@ | ||
/* eslint-disable react-compiler/react-compiler */ | ||
'use client' | ||
@@ -4,0 +2,0 @@ import * as React from 'react' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
717506
0.09%11
-8.33%8652
0.06%+ Added
- Removed
Updated