I am having the following error when I use the react-email package in my next.js project the problem is caused by the Tailwind component so when I comment it out it works but since I want to apply some classes to style my email any way I can get around this would be appreciated, thanks in advance!
Failed to compile
./node_modules\@react-email\tailwind\dist\index.mjs
ReactServerComponentsError:
You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.
Learn more: https://nextjs.org/docs/getting-started/react-essentials
Maybe one of these should be marked as a client entry "use client":
./node_modules\@react-email\tailwind\dist\index.mjs
./email\contact-form-email.tsx
./actions\sendEmail.ts
contact-form-email.tsx
import React from 'react'
import {
Html,Body,Head,Heading,Hr,Container,Preview,Section,Text
} from '@react-email/components';
// import {Tailwind} from '@react-email/tailwind'
type ContactFormEmailProps = {
message: string;
email: string;
}
export default function ContactFormEmail({message,email}: ContactFormEmailProps) {
return (
<Html>
<Head />
<Preview>New message from your portfolio website</Preview>
{/* <Tailwind> */}
<Body className="bg-gray-100 text-black">
<Container>
<Section className="bg-white borderBlack my-10 px-10 py-4 rounded-md">
<Heading className="leading-tight">You received the following message from the contact form.</Heading>
<Text>{message}</Text>
<Hr />
<Text>The sender's email is: {email}</Text>
</Section>
</Container>
</Body>
{/* </Tailwind> */}
</Html>
)
}
@/lib/utils
import? Because if that's a catch-all utils file, good bet that either directly or indirectly importsreact-dom/server
. – Janetjaneta@/lib/utils
file to the question so that you can see it has not caused the issue. – Borges@/lib/utils
,so i provided it to show you it did not caused the error. Then why I provided other files here because as you might have guessed it I needed to show every body how they use thecontact-form-emial.tsx
file so that it is clear. – BorgesApp
that does nothing except show an<h1>
or something, imports tailwind, and shows that error happening when we copy your code and run it. If it is what you say, then none of the code you're currently showing are necessary, but a minimal reproducible example is. – Janetjaneta