Bug: `renderToStaticMarkup` throws error on client components
React version: 19.0.0
Steps To Reproduce
- Create a client component with the
'use client'directive. - Create a server (universal) component that uses the client component.
- Call
renderToStaticMarkupwith 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.
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open.
Bump.
Same problem here. Bump.
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!
Bump.