Skip to content

Conversation

@thena-seer
Copy link
Contributor

Summary

For feature request #686 (comment)

Adds useRenderingOptions, which uses a React Context under the hood to pass the rendering options to the template.

Usage:

export const TemplateWithCustomPlainText: React.FC<Readonly<TemplateProps>> = ({ firstName }) => {
  const options = useRenderingOptions();

  if (options.plainText)
    return (
      <>
        <h1>Hello, {firstName}!</h1>
        <img alt="test" src="img/test.png" />
        <p>Thanks for trying our product.</p>
      </>
    )

  return (
    <>
      <h1>Welcome, {firstName}!</h1>
      <img alt="test" src="img/test.png" />
      <p>Thanks for trying our product. We're thrilled to have you on board!</p>
    </>
  )
};

Test plan

unit tests pass

@vercel
Copy link

vercel bot commented Feb 21, 2025

@thena-seer is attempting to deploy a commit to the resend Team on Vercel.

A member of the Team first needs to authorize it.

@gabrielmfern gabrielmfern force-pushed the canary branch 2 times, most recently from 391afdd to 8a7d9d0 Compare February 26, 2025 16:23
@changeset-bot
Copy link

changeset-bot bot commented Feb 26, 2025

⚠️ No Changeset found

Latest commit: 20136ef

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@@ -0,0 +1,26 @@
import { Options } from "./options";
Copy link
Member

@gabrielmfern gabrielmfern Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about this and I got to the conclusion that the uniqueRenderId would end up being used more often than not, and its ergonomic are not great for common use cases. If you can think of anything that would just work out-of-the-box like useContext lmk.

Let's use a context for now and in the future we'll think about how to make it work with react-markup.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, switched back to useContext

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, I'm not sure how to resolve the rsnd build error we're seeing in CI.

KayleeWilliams and others added 15 commits March 3, 2025 14:56
…1749)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: gabriel miranda <gabrielmfern@outlook.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bu Kinoshita <6929565+bukinoshita@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: gabriel miranda <gabrielmfern@outlook.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: gabriel miranda <gabrielmfern@outlook.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@thena-seer thena-seer force-pushed the use-rendering-options branch from e86e571 to d5fdaa5 Compare March 7, 2025 23:59
@gabrielmfern gabrielmfern force-pushed the canary branch 4 times, most recently from be584c9 to 0ab0f29 Compare May 1, 2025 12:59
@gabrielmfern gabrielmfern force-pushed the canary branch 2 times, most recently from ae17b61 to e62d722 Compare May 2, 2025 14:04
@gabrielmfern gabrielmfern force-pushed the canary branch 6 times, most recently from 2eba90b to 98c3d9b Compare May 16, 2025 13:02
@gabrielmfern gabrielmfern force-pushed the canary branch 3 times, most recently from 0074ddf to f7e553f Compare May 20, 2025 14:39
@gabrielmfern gabrielmfern force-pushed the canary branch 3 times, most recently from 61d045a to cee3eec Compare June 4, 2025 14:01
@gabrielmfern gabrielmfern force-pushed the canary branch 4 times, most recently from addf436 to ade5f69 Compare June 16, 2025 14:07
@gabrielmfern gabrielmfern force-pushed the canary branch 4 times, most recently from 3ff8597 to 3c4ea0a Compare June 30, 2025 13:13
@gabrielmfern
Copy link
Member

Sorry for taking so long, but I don't think we're going to be able to support it, sadly. For this to be supported, and we'd love to have it, we'd need to rethink how this gets implemented at the core, open to any ideas if anyone has some. But using a context isn't going to be sustainable, and already breaks in our web tests as was happening back in March.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants