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

fix(netlify-cms-core): duplicate key warning #1930

Merged
merged 2 commits into from
Dec 4, 2018

Conversation

barthc
Copy link
Contributor

@barthc barthc commented Dec 3, 2018

Summary
Fix the console warning on the workflow page

Warning: Encountered two children with the same key, .... Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.

that shows up when two entry from different collections both have the same slug. The issue shows for test-repo backend, not sure it would be the same case for github backend.

@verythorough
Copy link
Contributor

verythorough commented Dec 3, 2018

Deploy preview for netlify-cms-www ready!

Built with commit 0336614

https://deploy-preview-1930--netlify-cms-www.netlify.com

@verythorough
Copy link
Contributor

verythorough commented Dec 3, 2018

Deploy preview for cms-demo ready!

Built with commit 0336614

https://deploy-preview-1930--cms-demo.netlify.com

@erquhart
Copy link
Contributor

erquhart commented Dec 4, 2018

The index can change, so it isn't a reliable key. The slug should be unique, but it is possible for two entries from different collections to have the same slug. If you update to something like ${collection}-${slug}, that should work.

@barthc
Copy link
Contributor Author

barthc commented Dec 4, 2018

Yes I know the index key isn't reliable, but we are using it as keys in other places in the app 😊. So you want us to use ${collection}-${slug} in this case?

@erquhart
Copy link
Contributor

erquhart commented Dec 4, 2018

We use the index in other places if we know the order of a list won't change, in which case it's safe to use. This isn't one of those cases, so we need to consider what will be ensured unique. I believe ${collection}-${slug} will work, but that's assuming your bug experience was due to two entries from different collections with the same slug. If your bug is reproducible and you can confirm that ${collection}-${slug} fixes it, works for me 👍

@barthc
Copy link
Contributor Author

barthc commented Dec 4, 2018

Updated the key to ${collection}-${slug}

@erquhart
Copy link
Contributor

erquhart commented Dec 4, 2018

Thanks @barthc! Were you were able to confirm it addresses the bug you encountered?

@barthc
Copy link
Contributor Author

barthc commented Dec 4, 2018

@erquhart yes it did fix the bug.

@erquhart
Copy link
Contributor

erquhart commented Dec 4, 2018

Awesome 👍👍

@erquhart erquhart merged commit 9662eb2 into decaporg:master Dec 4, 2018
LoicMahieu added a commit to LoicMahieu/netlify-cms that referenced this pull request Dec 5, 2018
* official/master:
  update release ticker
  Publish
  feat: add cloudinary support (decaporg#1932)
  fix(netlify-cms-core): duplicate key warning (decaporg#1930)
  Update image.md (decaporg#1923)
  chore(netlify-cms-core): upgrade react-frame-component to 4.x (decaporg#1925)
  chore(netlify-cms-core): upgrade gray-matter to 4.x (decaporg#1924)
  feat(netlify-cms-widget-select): add support for multiple selection (decaporg#1901)

# Conflicts:
#	packages/netlify-cms-widget-select/package.json
#	packages/netlify-cms/src/media-libraries.js
LoicMahieu added a commit to LoicMahieu/netlify-cms that referenced this pull request Dec 7, 2018
…-config

* official/master: (48 commits)
  docs: fix broken link to dev configuration file (decaporg#1941)
  docs: link releases to tag comparisons
  update release ticker
  Publish
  feat: add cloudinary support (decaporg#1932)
  fix(netlify-cms-core): duplicate key warning (decaporg#1930)
  Update image.md (decaporg#1923)
  chore(netlify-cms-core): upgrade react-frame-component to 4.x (decaporg#1925)
  chore(netlify-cms-core): upgrade gray-matter to 4.x (decaporg#1924)
  feat(netlify-cms-widget-select): add support for multiple selection (decaporg#1901)
  chore: improve publish scripts
  Publish
  chore: test before publishing
  chore(netlify-cms-core): upgrade react-dnd to 7.x (decaporg#1922)
  chore(netlify-cms-widget-text): upgrade to react-textarea-autosize 7.x (decaporg#1921)
  chore(netlify-cms-core): upgrade to react-waypoint 8.x (decaporg#1920)
  fix(backend): use singular label in custom commit message (decaporg#1917)
  docs: add GAE-specific oAuth client (decaporg#1918)
  fix(netlify-cms-widget-text): set correct font family (decaporg#1916)
  chore(netlify-cms-core): upgrade redux and related dependencies (decaporg#1914)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants