server component + react query
Answered
MatheusDeveloper posted this in #help-forum
Good evening guys, I’m taking advantage of the carnival to give a study in react query with server components
What would be the best way, and if it would be possible for me to access this data at the moment it already brings the result
What would be the best way, and if it would be possible for me to access this data at the moment it already brings the result
Answered by aardani
const data = await getData()
qc.prefetchQuery({
queryKey:
queryFn: () => data
})31 Replies
@MatheusDeveloper Good evening guys, I’m taking advantage of the carnival to give a study in react query with server components
What would be the best way, and if it would be possible for me to access this data at the moment it already brings the result
you can separate the function and pass the data into the prefetch query
const data = await getData()
qc.prefetchQuery({
queryKey:
queryFn: () => data
})Answer
also what theme are you using?
And, how the best form to run my func data? useEffect?
About theme, i use polacode to take a print to code,
This config
that is in the server component, you can't use useEffect
thanks
i forgot this detail
@MatheusDeveloper And, how the best form to run my func data? useEffect?
what do you want to do?
@MatheusDeveloper I tried this way but it's complaining
what does the error say
i can't help you if you dont send enough information
Variable 'prefetchQuery' implicitly has an 'any' type.ts(7005)
whats your react query version
thats weird
"@tanstack/react-query": "^5.17.19",
can you update it to latest
5.20
because its doing just fine for me
while you're at it can you send the full code?
including the imports
Yes, thank you very much worked