useQuery with arguments?
react query question... so example from docs:
what if fetchToDoList requires params from form data? Which is my case... How am I supposed to pass fetchToDoList in this case when it requires 2 arguments that aren't accessible in the scope in my case?
3 Replies
flat-fuchsia•4y ago
Hi you should pass variable parts (arguments) in the query key which you can retrieve in your queryFn using the queryFunctionContext argument
Did you manage to have something working?
flat-fuchsia•4y ago
This is what I have in mind => https://tkdodo.eu/blog/leveraging-the-query-function-context
Leveraging the Query Function Context
Use what React Query provides for optimal type safety
ambitious-aqua•4y ago
this is a great question, thanks for sharing that article @glabat!