Comments (5)
You should stringify your function before using it as query key, since react-query checks if queryKey is a function, invokes it and uses returned value as key - see https://github.com/tannerlinsley/react-query/blob/master/src/index.js#L727.
In your case new Promise instance is used as query key, so new query is created on every render.
IMHO using strings or tuples (as suggested in docs) is much better option, but React Query isn't limited to it and of course you are free to use it as you want.
from query.
It's not a function, a query key is an array of function and variables [queryFn, variables]. Like I mentioned in an issue - that custom hook is take straight from react-query documentation:
// Heck, you can even make your own custom useQueryHook!
function useFunctionQuery(functionTuple, options) {
const [queryFn, variables] = Array.isArray(functionTuple)
? functionTuple
: [functionTuple]
return useQuery(functionTuple, queryFn, options)
}
from query.
@powah do you also use custom query key serializer?
from query.
Oops, I guess now I understand that I have to do that. Will try and thanks for the help!
from query.
You're welcome :)
from query.
Related Issues (20)
- Buggy interaction between returning filtered data in the combine property for useQueries function HOT 3
- Solid Query causes unnecessary rerender on every fetch when working with objects HOT 1
- docs: solid-start example new `app.config.ts` file HOT 1
- Docs: special behaviour of `initialDataUpdatedAt=0` is not documented HOT 3
- Solid Query+Astro: JavaScript heap out of memory HOT 1
- React component "tearing"/incorrectly stuck loading with `staleTime`/`enabled`/`queryKey` changes HOT 1
- `throwOnError` does not work with Angular HOT 3
- angular-adapter: does not re-render ui on signal changes HOT 1
- React Native, pnpm: Unable to resolve module @tanstack/query-core HOT 2
- Codemod for other (non-react) supported frameworks HOT 1
- queryClient.getQueryCache is not a function at ReactQueryDevtoolsPanel2 HOT 1
- `useQueries` + `skipToken` looses `.data` type inference HOT 6
- [solid-query] Using data in a show causes double-rendering after a transition HOT 1
- refetch returning stale data HOT 3
- react query dev tools has a black text color in dark mode HOT 1
- experimental_createPersister is not cleaning up after itself HOT 1
- [v4] Mutation Filters - mutation variables are missing from "options" HOT 1
- keepPreviousData doesn't work with useQueries HOT 1
- Devtools incorrectly assume the staleTime from a disabled query HOT 3
- passing queryFn: skipToken and enabled: true triggers onError of queryClient.queryCache HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from query.