I’m loving the Next 13 appdir support
Are we still required to use usePlasmicQueryData
when data fetching in plasmic components? or is there some special way to async/await
in server components?
I’m loving the Next 13 appdir support
Are we still required to use usePlasmicQueryData
when data fetching in plasmic components? or is there some special way to async/await
in server components?
Hey @efficient_pelican, you don’t need to use usePlasmicQueryData
in app dir. Instead, you can use async/await
in server components like normal apps.
Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.
i’m getting this error when I make it async
docs mention something like this here, but I’m not sure where to put the @ts-expect-error
- it doesn’t like it in the component file (guessing it goes wherever the component is used - but that’s plasmic)
Hi @efficient_pelican, sorry I misread your original question…
Are we still required to use
usePlasmicQueryData
when data fetching in plasmic components? or is there some special way toasync/await
in server components?
I thought you were asking if you need to useusePlasmicQueryData
to fetch data that you then pass into Plasmic components, so I suggested usingasync/await
.
But for writing a Plasmic code component, Code components cannot be server components, so you should still use usePlasmicQueryData
(or your own data fetching library). Note that all transitive dependencies of a code component also cannot be a server component, so the wrapper won’t help.
So sorry for the confusion
ok ok thank you
can descendants of a code component be server components?
Like my Product Page I wrap a code component around (product fetcher) - am i getting any benefit by this?
No, descendants may not be server components, since Plasmic components must work in a browser.
though, are the child components still compressed on server if they’re server compatible? bundle sizes are tiny after using appdir
With server components, they are completely omitted from the bundle.
Plasmic components only work on the client, so you can’t omit them, but they can be minified based on your app host.