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

fix(render): Import renderAsync function #912

Conversation

michael-dickinson-sainsburys
Copy link

@michael-dickinson-sainsburys michael-dickinson-sainsburys commented Sep 6, 2023

Fixes this error message when calling renderAsync function (#868):

✖ in ../node_modules/@react-email/components/node_modules/@react-email/render/dist/index.mjs 31:23-45
    export 'renderToReadableStream' (imported as 'renderToReadableStream') was not found in 'react-dom/server' (possible exports: renderToNodeStream, renderToPipeableStream, renderToStaticMarkup, renderToStaticNodeStream, renderToString, version)

@bukinoshita bukinoshita changed the title Fix: fix(renderAsync): Fix issue #868 by importing function correctly fix(render): Import renderAsync function Sep 12, 2023
@shellscape
Copy link

shellscape commented Sep 20, 2023

@michael-dickinson-sainsburys not getting that error on my end. what's the context under which this error occurred? bundling? tsc? which version, and which platform?

Here's a better fix that takes into account what the react docs have to say:

import react from 'react-dom/server';

const { renderToStaticMarkup } = react;
const renderToStream =
  // Note: only available in platforms that support WebStreams
  // https://react.dev/reference/react-dom/server/renderToString#alternatives
  react.renderToReadableStream ||
  // Note: only available in Node
  react.renderToPipeableStream;

export const renderToString = async (children: ReactNode) => {
  const stream = await renderToStream(children);

@gustavo-depaula
Copy link

@shellscape, I think this is solving this issue: #868

@shellscape
Copy link

Unfortunately it's not thorough enough to resolve the issue across several platforms.

@diegoholiveira
Copy link
Contributor

Any news about this issue?

@shellscape
Copy link

@diegoholiveira I ended up forking the project to get around issues like these. 😬

@devrsi0n
Copy link

Hi @bukinoshita , could you help take a look at this PR? Thank you in advance.

@bukinoshita
Copy link
Member

Yeah, we've been testing this. The canary.1 release is with this change, but it doesn't fix the issue

@gabrielmfern
Copy link
Collaborator

The error mentioned has been fixed in a better way and is already released, going to close this as it is not the optimal way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants