resend / react-email

💌 Build and send emails using React
https://react.email
MIT License
12.57k stars 571 forks source link

Markdown wrapped in Tailwind throws Error: marked(): input parameter is of type [object Array], string expected #1408

Closed Martiinii closed 4 weeks ago

Martiinii commented 1 month ago

Describe the Bug

When wrapping Markdown element with Tailwind, render/renderAsync throws error. Introduced somewhere between @react-email/tailwind@0.0.14 and 0.0.15. Full error is: Error: marked(): input parameter is of type [object Array], string expected Please report this to https://github.com/markedjs/marked.

 at Marked.parse (/home/martini/Documents/repos/react-email-starter/emails/test-email.tsx:239:34)
 at Function.marked [as parse] (/home/martini/Documents/repos/react-email-starter/emails/test-email.tsx:12:26)
 at MarkdownParser.parse (/home/martini/Documents/repos/react-email-starter/emails/test-email.tsx:17:24)
 at parseMarkdownToJSX2 (/home/martini/Documents/repos/react-email-starter/emails/test-email.tsx:9:16)
 at Markdown (/home/martini/Documents/repos/react-email-starter/emails/test-email.tsx:46:44)
 at f (/home/martini/Documents/repos/react-email-starter/emails/test-email.tsx:93077:28)
 at <unknown> (/home/martini/Documents/repos/react-email-starter/emails/test-email.tsx:93086:61)
 at <unknown> (/home/martini/Documents/repos/react-email-starter/emails/test-email.tsx:1158:16)
 at mapIntoArray (/home/martini/Documents/repos/react-email-starter/emails/test-email.tsx:1049:22)
 at Object.mapChildren [as map] (/home/martini/Documents/repos/react-email-starter/emails/test-email.tsx:1157:2)

Which package is affected (leave empty if unsure)

@react-email/tailwind

Link to the code that reproduces this issue

https://github.com/Martiinii/react-email-error

To Reproduce

With installed react-email server and min @react-email/tailwind@0.0.15 use this email:

const Email = () => {
    return (
        <Html>
            <Tailwind>
                <Markdown>{`# Hello, World!`}</Markdown>
            </Tailwind>
        </Html>
    );
};

Or use linked repo: npm i then npm run dev It will return an error Tailwind throws Error: marked(): input parameter is of type [object Array], string expected. I've managed to trace the error to first happen in 0.0.15 (haven't tested in canary versions).

Expected Behavior

Should render without throwing an error, just like in previous versions.

What's your node version? (if relevant)

No response

gabrielmfern commented 1 month ago

Interesting, this could be related to the changes on https://github.com/resend/react-email/releases/tag/%40react-email%2Fmarkdown%400.0.9 as well

Martiinii commented 1 month ago

Could be. I just want to clarify, in my project I've used latest @react-email/components and tested each Tailwind component from @react-email/tailwind versions and 0.0.14 was the last without this issue.

gabrielmfern commented 1 month ago

How about the latest canary for @react-email/ŧailwind @Martiinii? Does it also give the same error?

phl23 commented 1 month ago

worked for me with "0.0.16-canary.1"

If others want to use this as workaround, it's important to check that you import { Tailwind } from @react-email/tailwind and not from @react-email/components.

Martiinii commented 4 weeks ago

Can confirm, works in 0.0.16-canary.1. Use it as temporary solution.

johanneskares commented 2 weeks ago

It would be great to push this to a main release, soon. Lost about an hour trying to figure out why my emails weren't sending anymore. 🙏