#server component + react query

33 messages · Page 1 of 1 (latest)

humble atlas
#

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

upbeat runeBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

nova hornet
#
const data = await getData()
qc.prefetchQuery({
  queryKey:
  queryFn: () => data
})
#

also what theme are you using?

humble atlas
#

And, how the best form to run my func data? useEffect?

humble atlas
#

About theme, i use polacode to take a print to code,

nova hornet
#

that is in the server component, you can't use useEffect

humble atlas
#

This config

nova hornet
#

thanks

humble atlas
#

i forgot this detail

nova hornet
humble atlas
#

I tried this way but it's complaining

nova hornet
#

i can't help you if you dont send enough information

humble atlas
#

Variable 'prefetchQuery' implicitly has an 'any' type.ts(7005)

nova hornet
#

whats your react query version

#

thats weird

humble atlas
#

"@tanstack/react-query": "^5.17.19",

nova hornet
#

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

humble atlas
#

Yes

#

O i find the problem

#

a comma at the end of const data

nova hornet
#

ah nice

#

so all good?

#

@humble atlas

humble atlas
#

Yes, thank you very much worked