Skip to content
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

fix(react-email): Unwanted email re-renders when switching templates #1846

Open
wants to merge 10 commits into
base: canary
Choose a base branch
from

Conversation

gabrielmfern
Copy link
Collaborator

@gabrielmfern gabrielmfern commented Dec 27, 2024

The problem that was happening was something like this

CleanShot.2024-12-23.at.17.44.41.mp4

Every time the user navigated, even if it was to the same page already open, it would always re-render the email template, even if it was already rendered. When we first implemented the current architecture for the preview server, with Next.js 14, RSCs would always be cached in such a way that this navigation wouldn't re-render the RSC for the /preview/[slug] page, but as of Next.js 15 this does not seem to be the case.

The solution I chose for this was to store a cache for rendered emails in the server instead of in the client, this allows for the renderEmailByPath to return the cache when navigating across pages but also leads to less code and easier maintainability.

@gabrielmfern gabrielmfern self-assigned this Dec 27, 2024
Copy link

changeset-bot bot commented Dec 27, 2024

🦋 Changeset detected

Latest commit: 0b2e02f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
react-email Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Dec 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-email ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 27, 2024 9:19pm
react-email-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 27, 2024 9:19pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
App: Preview Package: react-email This is the CLI we generally use as just `email` on the temrinal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant