REPOST:Error: async/await is not yet supported in Client Components, only Server Components...
Answered
dank() posted this in #help-forum
dank()OP
why is my SideBarLinks component throwing that error? this is how my components are structured and laid out(Only the relevant code) https://codesandbox.io/p/sandbox/distracted-star-98y57h?file=%2Fapp%2Fcontent%2Fcomponents%2FsideBar%2FSideBarSegments.tsx%3A50%2C31
BTW it throws a different error on the sandbox env, not sure why.
layout.tsx //parent RSC
<ClientComponent>//index.tsx(sideBar)
<ServerComponent>//sideBarContent
<ClientComponent>//sideBarSegments
<ServerComponent>//SideBarLinks <------
</ServerComponent>
</ClientComponent>
</ServerComponent>
</ClientComponent>BTW it throws a different error on the sandbox env, not sure why.
Answered by aardani
if you want to not opt-into client components, you need to expose a property that you can pass down from a server component.
39 Replies
next.js doesnt work on codesandbox for some reason
dank()OP
that sucks
Have you tried reproducing in a minimal repo?
dank()OP
I'm gonna do that now, thought I'd make it in a sandbox and it would be more or less the same
dank()OP
yes that fixes it but I need it to be async
why can't I use async here?
your SidebarLinks is not a server component
SideBarLinks inside
SideBarSegments is a client component since SideBarSegments has use clientif you want to not opt-into client components, you need to expose a property that you can pass down from a server component.
Answer
@aardani if you want to not opt-into client components, you need to expose a property that you can pass down from a server component.
dank()OP
can you give me a simple example for clarity?
I thought it was as simple as
but if you pass a server component into a client comp then it's treated as a client com?
damn
"use client"
export function ClientComps({ children, foo, bar})// Server component (page.tsx/layout.tsx)
return(
<ClientComps
foo={<ServerComp2 />}
bar={<ServerComp3 />}
>
<ServerComp1 />
</ClientComps>
)dank()OP
I misunderstood it
pass it as children prop?
pass it as any prop is fine
dank()OP
but why is ServerComp1 not passed as a prop
incorrect, servercomp1 is pased as a prop
dank()OP
child?
okay
children to be exactdank()OP
what did I do wrong?
importing server comp into a client comp
dank()OP
okay okay I'm getting it
I got confused
@aardani so I should pass SideBarLinks into ProfileSegment in the SideBarContent right
but that also produces that error
it feels straightforward but it's not
it worked thanks so much I get it now, I really appreciate it!
saved my life
dont forget to mark the most helpful message as answer
dank()OP
okay lemme see
do you mark with just a reaction?
Original message was deleted