-
Notifications
You must be signed in to change notification settings - Fork 17
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
mjml-react does not seem to work in NextJS #106
Comments
Hi @bduff9 , thank you for reporting the problem. I have not worked with nextJS 13 too much, so I am not immediately sure what is going on here. I did narrow it down a bit more though. I tried to defined: const mjmlContent = (
<MjmlSection>
<MjmlColumn>
<MjmlText>Hello world</MjmlText>
</MjmlColumn>
</MjmlSection>
);
const htmlContent = (
<div>
<p>
<a>Hello world</a>
</p>
</div>
);
const mjmlStaticMarkup = ReactDOMServer.renderToStaticMarkup(mjmlContent);
const htmlStaticMarkup = ReactDOMServer.renderToStaticMarkup(htmlContent); and got back
So something is going on with the |
I tracked this down to a change in The quickest solution to your issue will be either:
As far as the long term solution, I am not certain yet. It seems like the naming of the mjml elements (e.g.
|
@emmclaughlin Thanks for looking into this. Unfortunately, downgrading to React 17 is not an option. I believe Next 13 requires React 18 but even if it doesn't, we use several React 18 features such as Suspense. As far as using a different method to convert JSX to a string, do you have any suggestions for that? It's not an area I have looked at much previously. |
I have not looked into it much. From a quick search here are some potential options to try: |
@emmclaughlin Thanks, I saw those too. Unfortunately, the first and third options only render the JSX string, not the HTML markup. The middle option just uses renderToStaticMarkup like mjml-react so that's a no-go too. I'll keep looking though, would love to use this library. Thanks again. |
@bduff9 I was worried that would be the case. I will keep looking to see if there is any other quick workaround that can unblock you here and let you know if I find anything |
For now I have solved this by using Also, if you are using app router like me (I have a simple previewer app for MJML react), then you want:
In your |
Update from the React team: facebook/react#27403 (comment) Sounds like it should be fixed in the next release 🙌 |
Closing this issue as we have tested mjml-react with the latest React canary builds and their fix is sufficient to reconcile this issue. |
Hello! I have been using mjml for quite some time and recently started a new project with nextJS 13 and this library. Unfortunately, something seems to be going wrong and I get an empty MJML string every time when I run renderToMjml:
I was able to recreate a minimal example only using the latest version of next and the latest version of this library here:
https://codesandbox.io/p/sandbox/nextjs-13-mjml-4yktfz
Any idea on why this is happening or how to fix? Thank you!
The text was updated successfully, but these errors were encountered: