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

feat(render): Add useRenderingOptions #1926

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

Conversation

thena-seer
Copy link

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

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
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
Collaborator

@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
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
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] <[email protected]>
Co-authored-by: gabriel miranda <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bu Kinoshita <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: gabriel miranda <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: dependabot[bot] <[email protected]>
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: 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 7 times, most recently from ceeaf0d to e7c671a Compare April 4, 2025 19:11
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