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: add "key" attribute to suppress react "key" warnings #238

Merged
merged 3 commits into from
Nov 24, 2024

Conversation

usualoma
Copy link
Member

b953beb

As @yusukebe pointed out in #233 (comment), template elements are written out as arrays, but without the key attribute, which caused a warning, has been fixed.

be543f3

There was no key attribute left in the content of the template element, which was exported by SSR, but when the element was restored by creatingElement on the client side, a warning was displayed due to the absence of the key attribute.

It may seem strange to add the key attribute with a sequential number, but these elements are not overwritten after rendering by the client, so there is no problem if the warning is avoided by adding a sequential number.

To suppress react key warnings in SSR.
To suppress react key warnings in runtime.
@usualoma
Copy link
Member Author

I am investigating the failure of the test...

@usualoma
Copy link
Member Author

bcb8fdc

We are using jsx directly for the performance, but with this change, we needed to remove the “key" from the props as follows, so we should stop using jsx directly and started using createElement.
https://github.com/honojs/hono/blob/44a50bdf55850ead9d36caf31d4b0a0b2586f08b/src/jsx/dom/index.ts#L52-L55

@usualoma
Copy link
Member Author

@yusukebe
Would you please review?

Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

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

LGTM!

@yusukebe
Copy link
Member

Hi @usualoma

These commits make sense. Looks good. I'll merge and release a new version. Thank you!

@yusukebe yusukebe merged commit 3d783f1 into honojs:main Nov 24, 2024
2 checks passed
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.

2 participants