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

Chip: unique "key" prop warning #7368

Closed
nNBee opened this issue Oct 24, 2024 · 5 comments · Fixed by #7369 or #7482
Closed

Chip: unique "key" prop warning #7368

nNBee opened this issue Oct 24, 2024 · 5 comments · Fixed by #7369 or #7482
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@nNBee
Copy link

nNBee commented Oct 24, 2024

Describe the bug

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

Check the render method of `Chip`. See https://reactjs.org/link/warning-keys for more information.
    at img
    at http://localhost:3000/node_modules/.vite/deps/primereact_chip.js?v=2ebc8c29:172:20

Reproducer

No response

System Information

System:
    OS: macOS 15.0.1
    CPU: (8) arm64 Apple M1
    Memory: 87.70 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.15.0 - ~/.nvm/versions/node/v20.15.0/bin/node
    npm: 10.7.0 - ~/.nvm/versions/node/v20.15.0/bin/npm
  Browsers:
    Brave Browser: 112.1.50.121
    Chrome: 130.0.6723.69
    Safari: 18.0.1
  npmPackages:
    primereact: ^10.8.4 => 10.8.4 
    react: ^18.3.1 => 18.3.1

Steps to reproduce the behavior

No response

Expected behavior

No response

@nNBee nNBee added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Oct 24, 2024
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Oct 24, 2024
@melloware melloware self-assigned this Oct 24, 2024
@melloware melloware added this to the 10.8.5 milestone Oct 24, 2024
melloware added a commit to melloware/primereact that referenced this issue Oct 24, 2024
@melloware
Copy link
Member

10.8.5 has not been released yet...

@nNBee
Copy link
Author

nNBee commented Nov 6, 2024

10.8.5 has not been released yet...

Yes, by the time I wrote it down, I realized that the new release hadn’t come out yet. Sorry...

@melloware
Copy link
Member

No worries!

@nNBee
Copy link
Author

nNBee commented Dec 6, 2024

Hi, thank you for the previous fixes! However, with version 10.8.5, the issue still persists, but I believe it is in the “Chip” component, not the “Chips” component.

The problem lies in the createContent function, specifically here:

if (props.image) {
    const imageProps = mergeProps(
        {
            src: props.image,
            onError: props.onImageError
        },
        ptm('image')
    );

    content.push(<img alt={props.imageAlt} {...imageProps} />);

In the content.push line, the img element does not have a key prop. I believe this is what causes the “Each child in a list should have a unique ‘key’” warning.

@melloware
Copy link
Member

Yep I see it fixing it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
2 participants