From d034c999be3af6bc9898e3d270d5651230fd9d36 Mon Sep 17 00:00:00 2001 From: Sindre Svendby Date: Mon, 1 Aug 2016 15:40:18 +0200 Subject: [PATCH 1/3] Checking the entire props and status for changes (deep) --- bundle-hash.js | 7 +------ dist/decorators/with-data.js | 3 +-- dist/decorators/with-visibility.js | 18 ++++++++++++++++++ package.json | 4 +++- src/decorators/with-data.js | 1 - src/decorators/with-visibility.js | 10 ++++++++++ 6 files changed, 33 insertions(+), 10 deletions(-) diff --git a/bundle-hash.js b/bundle-hash.js index 6f30385..efb1698 100644 --- a/bundle-hash.js +++ b/bundle-hash.js @@ -1,6 +1 @@ -/** - * This is just a placeholder - * for the bundle hash module - * (Will be overwritten during builds) - */ -module.exports = "no-builds-performed-yet"; +module.exports = "2a080b0e7d7a153bc313"; \ No newline at end of file diff --git a/dist/decorators/with-data.js b/dist/decorators/with-data.js index c197107..787ecc1 100644 --- a/dist/decorators/with-data.js +++ b/dist/decorators/with-data.js @@ -9,7 +9,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope */ var React = require('react'); var hoistStatics = require('hoist-non-react-statics'); - /** * Aurora mixins */ @@ -22,7 +21,7 @@ var DataMixin = require('../mixins/data-mixin'); module.exports = function (_ref) { var _ref$fetchData = _ref.fetchData; var fetchData = _ref$fetchData === undefined ? function () { - return Promise.resolve; + return Promise.resolve(); } : _ref$fetchData; var _ref$dataProp = _ref.dataProp; var dataProp = _ref$dataProp === undefined ? 'data' : _ref$dataProp; diff --git a/dist/decorators/with-visibility.js b/dist/decorators/with-visibility.js index 636b970..34d82df 100644 --- a/dist/decorators/with-visibility.js +++ b/dist/decorators/with-visibility.js @@ -5,6 +5,8 @@ */ var React = require('react'); var hoistStatics = require('hoist-non-react-statics'); +var sortedObject = require('sorted-object'); +var serialize = require('serialize-javascript'); /** * Export a decorator that @@ -55,6 +57,22 @@ module.exports = function (Component) { isVisible: !this.props._hideOnServer }; }, + shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) { + var nextPropsAdjusted = serialize(sortedObject(nextProps)); + var thisPropsAdjusted = serialize(sortedObject(this.props)); + + var nextStateAdjusted = serialize(sortedObject(nextState)); + var thisStateAdjusted = serialize(sortedObject(this.state)); + + var shouldUpdate = !(nextPropsAdjusted === thisPropsAdjusted && nextStateAdjusted === thisStateAdjusted); + if (shouldUpdate) { + console.log('Component.shouldUpdate: (newprops, oldprops)', nextPropsAdjusted, thisPropsAdjusted); + } else { + console.log('Component should not update'); + //console.log('Component.should not Update: (newprops, oldprops, nextState, thisState)', nextPropsAdjusted, thisPropsAdjusted, nextStateAdjusted, thisStateAdjusted); + } + return shouldUpdate; + }, /** diff --git a/package.json b/package.json index 3dc1462..5b4436a 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,8 @@ "homepage": "https://github.com/soldotno/aurora-core", "dependencies": { "async-each": "1.0.0", - "aurora-sass-loader": "soldotno/aurora-sass-loader.git#master", "aurora-deep-slice-merge": "soldotno/aurora-deep-slice-merge.git#master", + "aurora-sass-loader": "soldotno/aurora-sass-loader.git#master", "babel-polyfill": "6.9.1", "clean-css": "3.4.18", "css-loader": "0.23.1", @@ -51,6 +51,8 @@ "md5": "2.1.0", "no-op": "1.0.3", "qs": "6.2.0", + "serialize-javascript": "^1.3.0", + "sorted-object": "^2.0.0", "stringify-clone": "1.1.1", "url": "0.11.0" }, diff --git a/src/decorators/with-data.js b/src/decorators/with-data.js index d7e51c8..cd2a5ef 100644 --- a/src/decorators/with-data.js +++ b/src/decorators/with-data.js @@ -3,7 +3,6 @@ */ const React = require('react'); const hoistStatics = require('hoist-non-react-statics'); - /** * Aurora mixins */ diff --git a/src/decorators/with-visibility.js b/src/decorators/with-visibility.js index 698c2ec..2b49a95 100644 --- a/src/decorators/with-visibility.js +++ b/src/decorators/with-visibility.js @@ -3,6 +3,8 @@ */ const React = require('react'); const hoistStatics = require('hoist-non-react-statics'); +const sortedObject = require('sorted-object'); +const serialize = require('serialize-javascript'); /** * Export a decorator that @@ -53,6 +55,14 @@ module.exports = function(Component) { }; }, + shouldComponentUpdate(nextProps, nextState) { + // const nextPropsAdjusted = serialize(sortedObject(nextProps)); + // const thisPropsAdjusted = serialize(sortedObject(this.props)); + const nextStateAdjusted = serialize(sortedObject(nextState)); + const thisStateAdjusted = serialize(sortedObject(this.state)); + return !(nextStateAdjusted === thisStateAdjusted && serialize(sortedObject(nextProps)) === serialize(sortedObject(this.props))); + }, + /** * Handle updates with new props */ From 791ca259c83e19aeda53a3796aeff3574d4d11b6 Mon Sep 17 00:00:00 2001 From: Sindre Svendby Date: Mon, 1 Aug 2016 15:42:31 +0200 Subject: [PATCH 2/3] Adding build version --- dist/decorators/with-visibility.js | 15 +++------------ package.json | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/dist/decorators/with-visibility.js b/dist/decorators/with-visibility.js index 34d82df..06ff1a2 100644 --- a/dist/decorators/with-visibility.js +++ b/dist/decorators/with-visibility.js @@ -58,20 +58,11 @@ module.exports = function (Component) { }; }, shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) { - var nextPropsAdjusted = serialize(sortedObject(nextProps)); - var thisPropsAdjusted = serialize(sortedObject(this.props)); - + // const nextPropsAdjusted = serialize(sortedObject(nextProps)); + // const thisPropsAdjusted = serialize(sortedObject(this.props)); var nextStateAdjusted = serialize(sortedObject(nextState)); var thisStateAdjusted = serialize(sortedObject(this.state)); - - var shouldUpdate = !(nextPropsAdjusted === thisPropsAdjusted && nextStateAdjusted === thisStateAdjusted); - if (shouldUpdate) { - console.log('Component.shouldUpdate: (newprops, oldprops)', nextPropsAdjusted, thisPropsAdjusted); - } else { - console.log('Component should not update'); - //console.log('Component.should not Update: (newprops, oldprops, nextState, thisState)', nextPropsAdjusted, thisPropsAdjusted, nextStateAdjusted, thisStateAdjusted); - } - return shouldUpdate; + return !(nextStateAdjusted === thisStateAdjusted && serialize(sortedObject(nextProps)) === serialize(sortedObject(this.props))); }, diff --git a/package.json b/package.json index 5b4436a..296b30f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurora-core", - "version": "1.1.3", + "version": "1.1.4", "description": "Aurora Application Assembler Core", "main": "index.js", "engines": { From 0e1d405145e1c32c71590cf765df151f12583233 Mon Sep 17 00:00:00 2001 From: Sindre Svendby Date: Mon, 1 Aug 2016 15:45:23 +0200 Subject: [PATCH 3/3] Corrected package version to stable version --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 296b30f..676f74f 100644 --- a/package.json +++ b/package.json @@ -51,8 +51,8 @@ "md5": "2.1.0", "no-op": "1.0.3", "qs": "6.2.0", - "serialize-javascript": "^1.3.0", - "sorted-object": "^2.0.0", + "serialize-javascript": "1.3.0", + "sorted-object": "2.0.0", "stringify-clone": "1.1.1", "url": "0.11.0" },