Skip to content
This repository has been archived by the owner on Feb 20, 2020. It is now read-only.

Commit

Permalink
Merge pull request #21 from soldotno/deepCompare
Browse files Browse the repository at this point in the history
Deep compare
  • Loading branch information
SindreSvendby authored Aug 1, 2016
2 parents 40d12e0 + 0e1d405 commit c4421d3
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 11 deletions.
7 changes: 1 addition & 6 deletions bundle-hash.js
Original file line number Diff line number Diff line change
@@ -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";
3 changes: 1 addition & 2 deletions dist/decorators/with-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions dist/decorators/with-visibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -55,6 +57,13 @@ module.exports = function (Component) {
isVisible: !this.props._hideOnServer
};
},
shouldComponentUpdate: function shouldComponentUpdate(nextProps, nextState) {
// const nextPropsAdjusted = serialize(sortedObject(nextProps));
// const thisPropsAdjusted = serialize(sortedObject(this.props));
var nextStateAdjusted = serialize(sortedObject(nextState));
var thisStateAdjusted = serialize(sortedObject(this.state));
return !(nextStateAdjusted === thisStateAdjusted && serialize(sortedObject(nextProps)) === serialize(sortedObject(this.props)));
},


/**
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurora-core",
"version": "1.1.3",
"version": "1.1.4",
"description": "Aurora Application Assembler Core",
"main": "index.js",
"engines": {
Expand Down Expand Up @@ -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",
Expand All @@ -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"
},
Expand Down
1 change: 0 additions & 1 deletion src/decorators/with-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*/
const React = require('react');
const hoistStatics = require('hoist-non-react-statics');

/**
* Aurora mixins
*/
Expand Down
10 changes: 10 additions & 0 deletions src/decorators/with-visibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit c4421d3

Please sign in to comment.