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

Each child in a list should have a unique "key" prop. #55

Open
CaroFG opened this issue Apr 23, 2024 · 5 comments
Open

Each child in a list should have a unique "key" prop. #55

CaroFG opened this issue Apr 23, 2024 · 5 comments
Labels
good first issue Good for newcomers

Comments

@CaroFG
Copy link

CaroFG commented Apr 23, 2024

Description
Description of what the bug is about.
Using the provided example we get a react warning:

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

Check the render method of `Hits`. See https://reactjs.org/link/warning-keys for more information.

Expected behavior
What you expected to happen.
The example should provide a unique key to each hit, so that the warning is not triggered.

Current behavior
What happened.
The code sandbox hit component has a key property, but it does not remove the warning:

const Hit = ({ hit }) => (
  <div key={hit.id}>
    <div className="hit-name">
      <Highlight attribute="name" hit={hit} />
    </div>
    <img src={hit.image} align="left" alt={hit.name} />
    <div className="hit-description">
      <Snippet attribute="description" hit={hit} />
    </div>
    <div className="hit-info">price: {hit.price}</div>
    <div className="hit-info">release date: {hit.releaseDate}</div>
  </div>
);

Screenshots or Logs
If applicable, add screenshots or logs to help explain your problem.
Screenshot 2024-04-23 at 15 07 52

Environment (please complete the following information):

  • OS: [e.g. Debian GNU/Linux]
  • Browser: [e.g. Chrome version 90.0]
  • Meilisearch version: [e.g. v.0.20.0]
  • instant-meilisearch version: [e.g. v0.5.0]
  • react-instantsearch version: [e.g. v6.10.3]
  • React version: [e.g. 16.13.1]
@curquiza
Copy link
Member

@CaroFG are you sure it does not come from react-isntantsearch, so on the algolia side?

@CaroFG
Copy link
Author

CaroFG commented Apr 23, 2024

A user said it appeared when he moved from Algolia to Meilisearch, see Discord. As I told the user, I guess Algolia uses by default the objectID they generate for each document, but since we don't use an objectID we should probably provide an example that does not trigger a warning.

@curquiza
Copy link
Member

Thanks for the context!
Pinging this as good first issue

@curquiza curquiza added the good first issue Good for newcomers label Apr 23, 2024
@replyre
Copy link

replyre commented Apr 24, 2024

Hello, may I work on this issue?

@CaroFG
Copy link
Author

CaroFG commented Apr 24, 2024

Go ahead @replyre!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants