Skip to content

instanceof not working in preview-serverΒ #2688

@rothsandro

Description

@rothsandro

Describe the Bug

After updating to react-email v5 and installing @react-email/preview-server, the instanceof operator is not working anymore with JS built-in types like RegExp or Array.

The following email should render "true" but renders "false" in the preview. It works fine when rendering the email with @react-email/render.

const Demo = () => {
  return <div>{`${/.+/ instanceof RegExp}`}</div>;
};

export default Demo;

This breaks libraries like Zod when using z.templateLiteral(["foo", z.number()]) because they internally use the instanceof operator.

It affects the @react-email/preview-server package but that's not available in the list below.

Which package is affected (leave empty if unsure)

No response

Link to the code that reproduces this issue

https://github.com/rothsandro/repro.react-email-instanceof

To Reproduce

Render an email with the following content and run the preview server.

const Demo = () => <div>{`${/.+/ instanceof RegExp}`}</div>

Expected Behavior

instanceof should work for JS types as it did in v4

What's your node version? (if relevant)

22.19

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions