Chakra-ui: [RadioGroup/CheckboxGroup] Error: each child in a list should have a unique "key" prop

Created on 23 Mar 2020  ·  3Comments  ·  Source: chakra-ui/chakra-ui

When I use either a RadioGroup or a CheckboxGroup I get an error that I need to specify keys. When I add keys it'll still throw the same error.

<RadioGroup
  isInline
  spacing={4}
  defaultValue="301"
  ref={register}
  name="game"
  onChange={e => setGameType(e.target.value as GameTypes)}
  value={gameType}
>
  {gameTypes.map((type, index) => (
    <Radio value={type} key={index}>
      {type}
    </Radio>
  ))}
</RadioGroup>;
index.js:1 Warning: Each child in a list should have a unique "key" prop.

Check the render method of `RadioGroup`. See https://fb.me/react-warning-keys for more information.
    in Box (created by RadioGroup)
    in RadioGroup (at CreateGame.tsx:84)

Expected Behavior
When adding keys the error shoud be gone.

To Reproduce

  • Install @chakra-ui/core#0.6.1
  • Add a RadioGroup
  • Map over items in RadioGroup and return Radio Buttons
  • Check console

Desktop

  • Browser: Chrome 80.0.3987.149
Assigned ➡ Bug 🐛

Most helpful comment

This has been fixed. Kindly upgrade to the latest version

All 3 comments

I ran into this as well. I made a sandbox here: https://codesandbox.io/s/kind-chandrasekhar-xpmlc

Screen Shot 2020-03-24 at 11 35 14

Does a passed in key never make it to the wrapper box.

Screen Shot 2020-03-24 at 11 43 17

This has been fixed. Kindly upgrade to the latest version

That’s awesome, thanks man. I really love your library!

Was this page helpful?
0 / 5 - 0 ratings