Next.js Discord

Discord Forum

server component + react query

Answered
MatheusDeveloper posted this in #help-forum
Open in Discord
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
Answered by aardani
const data = await getData()
qc.prefetchQuery({
  queryKey:
  queryFn: () => data
})
View full answer

31 Replies

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
I tried this way but it's complaining
@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
O i find the problem
a comma at the end of const data
ah nice
so all good?
@MatheusDeveloper
Yes, thank you very much worked