client component using cookies + server SSR #74516
Replies: 1 comment
-
https://react.dev/reference/rsc/server-components
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
I have a client component that uses cookies to decide what to render. How can I get the server SSR to render the same initially, before hydration? I believe I can't use a server action because those are asynchronous and client components have to be synchronous.
I tried creating a HOC to pass the cookie value to the client component. The HOC returns a server component or client component which reads the cookie. However, using my server component like
<HOCServerComponent Component={Component} props={props}/>
gives⨯ [Error: Server Functions cannot be called during initial render. This would create a fetch waterfall. Try to use a Server Component to pass data to Client Components instead.]
. I don't know why next thinks it's a server function when the file looks like this:Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions