-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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: warning each child should have a unique key #1820
Conversation
This looks ok, I tested it locally with the patched code and it successfully fixed the warning. |
Can you add a test for this? @adrai This does not need to be done in this PR npm install @testing-library/react@^16.1.0 @types/react@^19.0.0 react@^19.0.0 react-dom@^19.0.0 react-test-renderer@^19.0.0 - "@testing-library/react": "^16.0.0",
+ "@testing-library/react": "^16.1.0",
- "@types/react": "^18.3",
+ "@types/react": "^19.0.0",
- "react": "^18.3.1",
+ "react": "^19.0.0",
- "react-dom": "^18.3.1",
+ "react-dom": "^19.0.0",
- "react-test-renderer": "^18.3.1",
+ "react-test-renderer": "^19.0.0", |
Can you create a PR for the deps update? |
|
|
merged and released with v15.1.4... please @ahmadfsalameh if possible create a new PR with a dedicated test for this |
Checklist
npm run test
@adrai @aiktb @XAOPT When I made the changes in #1813 I wasn't aware of the conditional return, It seems in the example provided here: https://stackblitz.com/edit/vitejs-vite-59g4bx?file=package.json the first if statement in
TransWithoutContext
is returning void causing the unmodified components (without key) to get rendered.That function handles both arrays and objects using
Object.keys
which is smart but also very confusing. We could revert my changes and the warning will disappear but it will cause errors to show up because those components are readonly, also as specified here in your type: https://github.com/i18next/react-i18next/blob/master/TransWithoutContext.d.ts#L16.In this pull request I'm attempting to solve both issues, mutating the component prop and the keys warning. I split the function into smaller functions which will return a new components value at the end without overriding it.
It might also fix #1733