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

ArrayField + SingleFieldList: if embedded data doesn't have an id, rows won't have a key and will cause a React warning #7614

Closed
smeng9 opened this issue May 2, 2022 · 1 comment · Fixed by #7617

Comments

@smeng9
Copy link
Contributor

smeng9 commented May 2, 2022

What you were expecting:

Using an ArrayField + SingleFieldListfor embedded data that doesn't have an id prop should work without console errors

What happened instead:

I get this error in the console: Warning: Each child in a list should have a unique "key" prop.

Steps to reproduce:

  1. Goto https://hs0dpi.sse.codesandbox.io/#/posts/12/show
  2. Open console to see the warning

Related code:

https://codesandbox.io/s/stoic-glade-hs0dpi?file=/src/posts/PostShow.tsx:1269-1446

Other information:

This is where the key is set based on the id, which doesn't exist in this case:

https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/list/SingleFieldList.tsx#L102

Environment

  • React-admin version: 4.0.2
  • Last version that did not exhibit the issue (if applicable):
  • React version: 18.1.0
  • Browser:
  • Stack trace (in case of a JS error):
@smeng9
Copy link
Contributor Author

smeng9 commented May 2, 2022

Duplicate of #7541

The fix should be similar to #7548 and just one or two lines

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

Successfully merging a pull request may close this issue.

2 participants