diff --git a/src/internal-packages/crud/lib/component/document-list.jsx b/src/internal-packages/crud/lib/component/document-list.jsx index 66d4047a494..adec82cc1db 100644 --- a/src/internal-packages/crud/lib/component/document-list.jsx +++ b/src/internal-packages/crud/lib/component/document-list.jsx @@ -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 */ @@ -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); } /** diff --git a/src/internal-packages/crud/lib/store/reset-document-list-store.js b/src/internal-packages/crud/lib/store/reset-document-list-store.js index cdfb49a1c18..0503defc43a 100644 --- a/src/internal-packages/crud/lib/store/reset-document-list-store.js +++ b/src/internal-packages/crud/lib/store/reset-document-list-store.js @@ -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. */