Skip to content

Commit

Permalink
use lodash's isEqual for property comparison (aksonov#1682)
Browse files Browse the repository at this point in the history
exclude functions from equality checks
  • Loading branch information
barakcoh authored and aksonov committed Mar 7, 2017
1 parent bdc39da commit 9dcef8a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
}
],
"dependencies": {
"lodash.isequal": "^4.5.0",
"react": "^15.4.2",
"react-addons-pure-render-mixin": "^15.4.2",
"react-dom": "^15.4.2",
Expand Down
9 changes: 4 additions & 5 deletions src/Reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@
/* eslint-disable no-param-reassign */

import { Platform } from 'react-native';
import isEqual from 'lodash.isequal';
import * as ActionConst from './ActionConst';
import { ActionMap } from './Actions';
import { assert } from './Util';
import { getInitialState } from './State';

// WARN: it is not working correct. rewrite it.
function checkPropertiesEqual(action, lastAction) {
let isEqual = true;
for (const key of Object.keys(action)) {
if (['key', 'type', 'parent'].indexOf(key) === -1) {
if (action[key] !== lastAction[key]) {
isEqual = false;
if (!isEqual(action[key], lastAction[key]) && (typeof action[key] !== 'function') && (typeof lastAction[key] !== 'function')) {
return false;
}
}
}
return isEqual;
return true;
}

function resetHistoryStack(child) {
Expand Down

0 comments on commit 9dcef8a

Please sign in to comment.