Skip to content

fix(tailwind): React.forwardRef components not working #1335

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

Merged
merged 11 commits into from
Apr 3, 2024

Conversation

nzben
Copy link
Contributor

@nzben nzben commented Feb 29, 2024

We were finding that some components in our UI library were not being correctly rendered.

On investigation it appears that in a couple of places in the Tailwind component, there's a check to see if the child is a functional component. For example:

if (typeof modifiedElement.type === "function") {

When using React.forwardRef, the child appears as an object with a render function, which was failing this test.

Unsure if there's a better option, but this PR expands the check to also see if the child has a render function and uses that instead of the child itself.

Copy link

vercel bot commented Feb 29, 2024

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

Name Status Preview Comments Updated (UTC)
react-email-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 2, 2024 8:08pm

Copy link

vercel bot commented Feb 29, 2024

@nzben is attempting to deploy a commit to the resend Team on Vercel.

A member of the Team first needs to authorize it.

@gabrielmfern
Copy link
Collaborator

Can you also run pnpm format on the root of the code in the fork's branch?

@gabrielmfern gabrielmfern changed the title fix(react-email/tailwind): Fix tailwind component to work with React.forwardRef components fix(react-email/tailwind): React.forwardRef components not working Mar 4, 2024
@gabrielmfern gabrielmfern changed the title fix(react-email/tailwind): React.forwardRef components not working fix(tailwind): React.forwardRef components not working Mar 6, 2024
@gabrielmfern gabrielmfern added Package: @react-email/tailwind Type: Bug Confirmed bug PR: In Review This PR is in the process of being reviewed by the team labels Mar 6, 2024
@gabrielmfern
Copy link
Collaborator

gabrielmfern commented Apr 1, 2024

@nzben Could you check the "Allow edits and access to secrets by mantainers" option? This is so that I can fix the conflicts here.

Wanted to get this one merged.

@nzben
Copy link
Contributor Author

nzben commented Apr 2, 2024

@gabrielmfern weirdly, I don't see that option :(
CleanShot 2024-04-02 at 18 46 48@2x

I'll try to merge upstream and fix the conflict.

@gabrielmfern
Copy link
Collaborator

@nzben Weird that it doesn't appear even though GitHub mentions it 🤔

Would be awesome if you could fix the conflicts. This PR should actually fix #1391 as well, so really wanted to get this merged.

@gabrielmfern
Copy link
Collaborator

@nzben You can also try reopening the PR here, from the same branch and fork, with the option checked so that I can fix the conflicts.

@nzben
Copy link
Contributor Author

nzben commented Apr 2, 2024

Should be good to go now @gabrielmfern

@gabrielmfern gabrielmfern merged commit 93ffa8b into resend:canary Apr 3, 2024
@gabrielmfern
Copy link
Collaborator

Thank you so much @nzben. Just merged it, will release in a few. Loved this PR, feel free to open other ones if you find the need to 🥰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: @react-email/tailwind PR: In Review This PR is in the process of being reviewed by the team Type: Bug Confirmed bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants