Skip to content

TextDecoder is not defined when running email dev #1258

Closed
@ffiona

Description

@ffiona

Describe the Bug

I'm not sure if it's a bug or my specific usage of the react-emal, but everything worked as expected before "react-email": "2.0.0". Last working version is 1.9.1.

I want to see pre-rendered emails in the preview so my export default function is an output of the render utility.

Screenshot 2024-01-26 at 15 39 15

Which package is affected (leave empty if unsure)

react-email

Link to the code that reproduces this issue

https://github.com/resend/react-email

To Reproduce

Here is an example of my email:

import { Text, Tailwind, Head, Body, Html, render } from '@react-email/components';
import * as React from 'react';
import { CustomTailwindConfig } from './type_system/styles/tailwind.config';

export function Template(props) {
  const { cardText } = props;

  return (
    <Tailwind
      config={CustomTailwindConfig}>
      <Head />
      <Body
        className="bgColor-body">
        <Text>
          {cardText}
        </Text>
      </Body>
    </Tailwind>
  );
}

export function Email() {

  const emailHtml = render(
    <Template
      cardText="Test"
    />, {
      pretty: false,
    }
  );

  const doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
  const rawEmail = emailHtml.replace(doctype,'');

  return (
    <Html dangerouslySetInnerHTML={{ __html: rawEmail }}></Html>
  );
}

export default Email;

Expected Behavior

Just a working desktop & source preview:

Screenshot 2024-01-26 at 17 09 49 Screenshot 2024-01-26 at 17 10 14

What's your node version? (if relevant)

18.17.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: react-emailThis is the CLI we generally use as just `email` on the temrinal.Type: BugConfirmed bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions