nursery/useTanstackQueryStableQueryClient
nursery · since 2.6.5
Unsafe autofixRecommended
biome.json
{
"linter": {
"rules": {
"nursery": {
"useTanstackQueryStableQueryClient": "error"
}
}
}
}Require the TanStack Query QueryClient to be created once, not on every render.
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
function App() {
const queryClient = new QueryClient();
return (
<QueryClientProvider client={queryClient}>
<Home />
</QueryClientProvider>
);
}import { QueryClient } from "@tanstack/react-query";
const useQueryClient = () => {
const queryClient = new QueryClient();
return queryClient;
};import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { useState } from "react";
const sharedClient = new QueryClient();
function App() {
const [queryClient] = useState(() => new QueryClient());
return (
<QueryClientProvider client={queryClient}>
<Home />
</QueryClientProvider>
);
}
async function ServerComponent() {
const queryClient = new QueryClient();
await queryClient.prefetchQuery(options);
}Examples from the Biome documentation.
ESLint does not have this rule.
Oxlint does not have this rule.
nursery/useTanstackQueryStableQueryClient
nursery · since 2.6.5
{
"linter": {
"rules": {
"nursery": {
"useTanstackQueryStableQueryClient": "error"
}
}
}
}Enforce that onMutate comes before onError and onSettled in the options of TanStack Query mutations.
Enforce a consistent property order in the options of TanStack Query infinite query functions.
Require query keys to include every value that the query function uses.
Disallow the use of undeclared environment variables.