Skip to content
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

Two children with same key Error #221

Closed
meinhoonharsh opened this issue Feb 24, 2022 · 4 comments
Closed

Two children with same key Error #221

meinhoonharsh opened this issue Feb 24, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@meinhoonharsh
Copy link

If we pass an array as a value, It will produces Error name Warning: Encountered two children with same keys

image

Steps to Reproduce

  • Pass an array of objects to options where key value of any object is an array, like this
const options = [
        { label: "Albania", value: [1,2,2,3,34,4] },
        { label: "Argentina", value: 54 },
    ];
  • Start your Server and open Console to see logs
  • Click on the select and view logs
@meinhoonharsh
Copy link
Author

@sanusart @voneiden @pattiereaves I want to work on this issue

@sanusart
Copy link
Owner

Feel free to do so

@sanusart sanusart added the bug Something isn't working label Mar 20, 2022
@WardenSlayer
Copy link

If we pass an array as a value, It will produces Error name Warning: Encountered two children with same keys

image

Steps to Reproduce

  • Pass an array of objects to options where key value of any object is an array, like this
const options = [
        { label: "Albania", value: [1,2,2,3,34,4] },
        { label: "Argentina", value: 54 },
    ];
  • Start your Server and open Console to see logs
  • Click on the select and view logs

Hey, I had this same error occur and I pulled my hair out for a while. But then I figured it out.
The options keyword is looking for an array of objects [{label,value},{label,value},...etc] to be passed into it. If you just pass in the objects {} you get the duplicate key error because even though the objects contain different data, they are being treated as the same. What I did to fix my issue was to use a {label,'tag'} which I later used the tag to find the actual object as part of the "onchange" call

@sanusart
Copy link
Owner

sanusart commented Mar 24, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants