Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/internal-packages/crud/lib/component/document-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const InsertDocumentStore = require('../store/insert-document-store');
const InsertDocumentDialog = require('./insert-document-dialog');
const Actions = require('../actions');

// const debug = require('debug')('mongodb-compass:crud');
// const debug = require('debug')('mongodb-compass:crud:component');

/* eslint no-return-assign:0 */

Expand Down Expand Up @@ -66,10 +66,17 @@ class DocumentList extends React.Component {
* @returns {Boolean} If the component should update.
*/
shouldComponentUpdate(nextProps, nextState) {
return (nextState.docs.length !== this.state.docs.length) ||
(nextState.nextSkip !== this.state.nextSkip) ||
(nextState.loadedCount !== this.state.loadedCount) ||
(nextState.namespace !== this.state.namespace);
// compare the states if they're different update component
if ((nextState.docs.length !== this.state.docs.length)
|| (nextState.nextSkip !== this.state.nextSkip)
|| (nextState.loadedCount !== this.state.loadedCount)
|| (nextState.namespace !== this.state.namespace)
|| (nextState.count !== this.state.count)) {
return true;
}

// at this point compare the documents themselves and update if not different
return !_.isEqual(nextState.docs, this.state.docs);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const toNS = require('mongodb-ns');

// const debug = require('debug')('mongodb-compass:crud');

// const debug = require('debug')('mongodb-compass:crud:store');

/**
* The default read preference.
*/
Expand Down