Capgemini / dcx-react-library

React Library UI/UX agnostic
https://main--6069a6f47f4b9f002171f8e1.chromatic.com
MIT License
107 stars 7 forks source link

Warning: Each child in a list should have a unique "key" prop. found in Tab component #538

Closed Ibabalola closed 9 months ago

Ibabalola commented 9 months ago

Describe the bug Warning: Each child in a list should have a unique "key" prop.

Check the top-level render call using

. See https://reactjs.org/link/warning-keys for more information. at /.../node_modules/@capgeminiuk/dcx-react-library/dist/dcx-react-library.js:2039:3

To Reproduce Render the compoent

Expected behavior No warning

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • Chrome Version 117.0.5938.92
  • Mac OS
daniele-zurico commented 9 months ago

we have quite a lot of components available now in the library, can you please tell me which one is creating the problem to your side please?

Ibabalola commented 9 months ago

TabGroup component

alexwbbr commented 9 months ago

@daniele-zurico and @Ibabalola I have looked into this and found a solution. The part of tab group that is causing the problem is they key property on line 174 which is rendering the content of the currently active tab. Can the user ever see more than one tab content at the same time? If they can't then why is the active tab content being treated like an array when you can just render the one shown and remove the key property.

alexwbbr commented 9 months ago

Never mind, saw the failing test for my solution and have another. Which branch should I use to make my pr? @daniele-zurico

daniele-zurico commented 9 months ago

fixed by #540