Skip to content

Commit 495cd45

Browse files
durranimlucas
authored andcommitted
COMPASS-134: Backport: Use uuids for document list keys (#583)
1 parent 41d2305 commit 495cd45

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/internal-packages/crud/lib/component/document-list.jsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const _ = require('lodash');
22
const React = require('react');
3+
const uuid = require('node-uuid');
34
const app = require('ampersand-app');
45
const Action = require('hadron-action');
56
const ObjectID = require('bson').ObjectID;
@@ -191,12 +192,10 @@ class DocumentList extends React.Component {
191192
/**
192193
* Get the key for a doc.
193194
*
194-
* @param {Document} doc - The document.
195-
*
196195
* @returns {String} The unique key.
197196
*/
198-
_key(doc) {
199-
return `${NamespaceStore.ns}_${JSON.stringify(doc._id)}`;
197+
_key() {
198+
return uuid.v4();
200199
}
201200

202201
/**
@@ -222,7 +221,7 @@ class DocumentList extends React.Component {
222221
renderDocuments(docs) {
223222
return _.map(docs, (doc) => {
224223
return (
225-
<li className="document-list-item" key={this._key(doc)}>
224+
<li className="document-list-item" key={this._key()}>
226225
<Document doc={doc} key={this._key(doc)} editable />
227226
</li>
228227
);

0 commit comments

Comments
 (0)