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

Remove children from props of ErrorMessage when using component #87

Merged
merged 2 commits into from
Dec 3, 2021

Conversation

IanVS
Copy link
Contributor

@IanVS IanVS commented Sep 22, 2021

I tried using ErrorMessage in my own project with an as component that takes children as a prop. Because of the way the typescript is set up, it forced me to also add children to the ErrorMessage, even though it ends up getting replaced with the actual error message.

The change here removes children from the props when using a component in as.

I also added a pair of tests for components, since those were missing. I think one snapshot is revealing that the behavior is different from what's specified in the README, but I didn't tackle that change here, it can be done in another PR if it is indeed a bug.

Comment on lines +19 to +22
exports[`ErrorMessage should render correctly with flat errors and as with component and render 1`] = `
<DocumentFragment>
flat
</DocumentFragment>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This looks incorrect. According to the README, the as should take precedence, but that seems to only apply to elements provided in as, not components.

Copy link
Member

Choose a reason for hiding this comment

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

@lanvs oh... you are right!
We need to fix this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you need me to try to work on it in this PR, or can that maybe be a separate effort?

Copy link
Member

Choose a reason for hiding this comment

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

Let's merge this once 👍🏻
If you are willing to help, we would like you to create another PR 🙏🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll see what I can do, but TBH I'm stretched a bit thin at the moment.

@bluebill1049
Copy link
Member

thanks for the PR 👍

@IanVS
Copy link
Contributor Author

IanVS commented Dec 2, 2021

Hi there, any word on this? @kotarella1110 are you able to take a look? Thanks!

Copy link
Member

@kotarella1110 kotarella1110 left a comment

Choose a reason for hiding this comment

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

Thanks for your PR! 🎉

Comment on lines +19 to +22
exports[`ErrorMessage should render correctly with flat errors and as with component and render 1`] = `
<DocumentFragment>
flat
</DocumentFragment>
Copy link
Member

Choose a reason for hiding this comment

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

@lanvs oh... you are right!
We need to fix this.

@bluebill1049 bluebill1049 merged commit 81b0492 into react-hook-form:master Dec 3, 2021
@bluebill1049
Copy link
Member

Thanks @IanVS and @kotarella1110

@IanVS IanVS deleted the children-typescript branch December 3, 2021 21:55
@IanVS
Copy link
Contributor Author

IanVS commented Dec 3, 2021

Thanks both of you. I've created #88 to track the as issue identified above.

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.

3 participants