Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: renderToStaticMarkup throws error on client components #32715

Open
jonathanhefner opened this issue Mar 23, 2025 · 0 comments
Open

Bug: renderToStaticMarkup throws error on client components #32715

jonathanhefner opened this issue Mar 23, 2025 · 0 comments
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@jonathanhefner
Copy link
Contributor

React version: 19.0.0

Steps To Reproduce

  1. Create a client component with the 'use client' directive.
  2. Create a server (universal) component that uses the client component.
  3. Call renderToStaticMarkup with the server component.

Link to code example: https://codesandbox.io/p/devbox/keen-williamson-wg9p8w (using Next.js to demonstrate 'use client')

The current behavior

renderToStaticMarkup throws an Error when it encounters a client component:

Error: Attempted to call MyClientComponent() from the server but MyClientComponent is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.

The expected behavior

When renderToStaticMarkup encounters a client component, it renders non-interactive HTML for the component, just as pre-rendering would during SSR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

1 participant