Can I pass refetch as a prop?
Title basically..
The thing is that I am fetching all of my items in component#1, I use them there and I also pass them as a prop to component#2, there I can create a new item. thing is that I would like to use the refetch function in component#2 that comes along the useQuery (which is in component#1).
Is it even something I should do or is it a bad design choice on my end?
How do I approach this issue?
19 Replies
https://tanstack.com/query/v4/docs/react/reference/QueryClient#queryclientrefetchqueries
Example
Look into refetching
what would the query key look like in mycase?
in this case is my query key task.getAll ?
good question
maybe lol
I've tried task, task.getAll, capitalized and non capitalized, nothing works lol
using
works but it refetches all of my queries
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
You can use react query devtools to see query keys 😉
What if he has to do it somewhere else 😂 it’s a temporary solution
The refetch function type is something ridiculous and doesn’t work
Will try!
I dug a little deeper
Or
Just tested, this works
For some reason this wont work at all for me locally, not even calling refetch 🤣 I think I just broke my app somehow but should work for you lol
lol
Maybe calling with utils is more logical than getQueryKey
But yh
Good to see it's working for you
its great
its still very interesting that u have to dig out everything like all of this stuff is very new
Only reason I got this was just cuz I had forgotten this was a thing
It's not new lel
I'm just potato
i mean the integration between everything..
I even resorted to chatgpt but nothing of value was found
chatgpt is like up till 2019 or something no?
trpc is after 2019
Like googling most of my issues isnt as effective as it it was
i mean with other stacks
t3 stack is quite new yh was fun seeing the cli transform from a little potato to adding stuff and it becoming more and more complex