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

Warning: Each child in a list should have a unique "key" prop; #6134

Closed
AndriiPetrashchukEmpeek opened this issue Apr 8, 2021 · 5 comments · Fixed by #6146
Closed

Warning: Each child in a list should have a unique "key" prop; #6134

AndriiPetrashchukEmpeek opened this issue Apr 8, 2021 · 5 comments · Fixed by #6146
Assignees
Labels

Comments

@AndriiPetrashchukEmpeek
Copy link

AndriiPetrashchukEmpeek commented Apr 8, 2021

I got the error "Warning: Each child in a list should have a unique "key" prop;"
when I used the "SimpleList" component;

Example
<SimpleList
primaryText={record => record.email}
secondaryText={record => record.roleId}
tertiaryText={record => (record.isActive ? 'Active' : 'Inactive')}
linkType="edit"
/>

Environment

  • React-admin version: ^3.12.2
  • React version: ^17.0.1
  • Browser: Google Chrome
@djhi
Copy link
Collaborator

djhi commented Apr 8, 2021

Thanks for reporting this. Please provide a sample application showing the issue by forking the following CodeSandbox (https://codesandbox.io/s/github/marmelab/react-admin/tree/master/examples/simple).

@fzaninotto
Copy link
Member

I confirm that I can't reproduce the problem with the simple example (where PostList renders a SimpleList on small screens). Could it be that some of the records in your list share the same id?

@fzaninotto
Copy link
Member

I managed to reproduce the problem by slowing down the dataProvider. The problem lies in the SimpleListLoading component.

@aenonGit
Copy link

what if the items do not have ids? This is my case and I get the same error in console

@slax57
Copy link
Contributor

slax57 commented Oct 29, 2024

@aenonGit As stated in the docs:

React-admin requires that each resource has an id field to identify it. If your API uses a different name for the primary key, you have to map that name to id in your dataProvider.

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

Successfully merging a pull request may close this issue.

5 participants