-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[react@19] Using <Trans />
with the components
prop gives an error 'Each child in a list should have a unique "key" prop.'
#1805
Comments
it's just a "warning"... |
Object.keys(components).forEach((c) => {
+ components[c] = cloneElement(components[c], { key: c });
const comp = components[c]; I tested this locally and it removes the warning, is this correct? |
Maybe better like this? Object.keys(components).forEach((c, i) => {
if (!components[c].key) components[c] = cloneElement(components[c], { key: i });
const comp = components[c]; |
Is it necessary to use index? |
yes, that is also ok... but since the components can be defined as object or as array, I was thinking to streamline this to ensure it's always the index |
🐛 Bug Report
When using react@19, the
Trans
component throws an error. It has been confirmed that react@18 does not have this issue, and this error does not affect the normal operation of i18next.This issue has a low priority because react@19 has not been officially released yet.
To Reproduce
https://stackblitz.com/edit/vitejs-vite-ufa4wi?file=src%2FApp.tsx,package.json
The sample code is from the react-i18next document:
This error has been known to be eliminated using
<i key="1"/>
.Expected behavior
No error.
Your Environment
The text was updated successfully, but these errors were encountered: