Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Chunks populated with duplicate keys #4966

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

Open
Kireki opened this issue Apr 7, 2025 · 1 comment
Open

Chunks populated with duplicate keys #4966

Kireki opened this issue Apr 7, 2025 · 1 comment
Labels

Comments

@Kireki
Copy link

Kireki commented Apr 7, 2025

Which package?

Encountered on [email protected], but reproducible on [email protected] and onwards

Describe the bug

After this commit it seems that React node chunks are being injected with hardcoded key props. This results in numerous warnings in the console etc.

Looks to be caused by toArbitrarilyKeyedReactNode here:
5709220#diff-3f3eca6b8934a329c2b948cf0c6aa17d25892fbc510accb92734ceb96a03a3e7R42-R46

To Reproduce

Make a source string like:

{
     "sourceString": "This is a react node value: {value}. And another react node {value1}"
}

And the use that message like:

<FormattedMessage id="sourceString" values={{ value: <b>node1</b>, value1: <b>node2</b> }} />

Codesandbox URL

https://codesandbox.io/p/sandbox/fqccvj (React)
https://codesandbox.io/p/sandbox/purple-leaf-85qgsq (Preact - what we use specifically)

as the messages are shown only in development builds, these are more just to give a better idea of the issue :)

Expected behavior

No duplicate keys among simbling nodes and no warning messages.

Screenshots

Image

Desktop (please complete the following information):

  • OS: MacOS
  • Browser Google Chrome
  • Version 134.0.6998.166
@Kireki Kireki added the bug label Apr 7, 2025
@Kireki
Copy link
Author

Kireki commented Apr 7, 2025

After some more digging found this to be valid for Preact only. As stated in the comments, React does it's own magic with Children.map and avoids the issue 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant