From 44ea2efdab31ab398826939fb5a3280a598f0198 Mon Sep 17 00:00:00 2001 From: maxim Date: Sun, 9 Apr 2017 09:30:45 +0200 Subject: [PATCH 1/2] Replaced ES6 instance methods with static one --- src/JSONNestedNode.js | 2 +- src/index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/JSONNestedNode.js b/src/JSONNestedNode.js index fea227c..799ffda 100644 --- a/src/JSONNestedNode.js +++ b/src/JSONNestedNode.js @@ -110,7 +110,7 @@ export default class JSONNestedNode extends React.Component { } shouldComponentUpdate(nextProps, nextState) { - return !!Object.keys(nextProps).find(key => + return !!Array.find(Object.keys(nextProps), key => key !== 'circularCache' && (key === 'keyPath' ? nextProps[key].join('/') !== this.props[key].join('/') : diff --git a/src/index.js b/src/index.js index 3d4b074..85b5c54 100644 --- a/src/index.js +++ b/src/index.js @@ -109,13 +109,13 @@ export default class JSONTree extends React.Component { } componentWillReceiveProps(nextProps) { - if (['theme', 'invertTheme'].find(k => nextProps[k] !== this.props[k])) { + if (Array.find(['theme', 'invertTheme'], k => nextProps[k] !== this.props[k])) { this.setState(getStateFromProps(nextProps)); } } shouldComponentUpdate(nextProps) { - return !!Object.keys(nextProps).find(k => ( + return !!Array.find(Object.keys(nextProps), k => ( k === 'keyPath' ? nextProps[k].join('/') !== this.props[k].join('/') : nextProps[k] !== this.props[k] From 5d68a4021c5d4f6df2c7cda0d266901ff3a59088 Mon Sep 17 00:00:00 2001 From: maxim Date: Sun, 9 Apr 2017 14:29:25 +0200 Subject: [PATCH 2/2] sortObjectKeys fix --- src/getCollectionEntries.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/getCollectionEntries.js b/src/getCollectionEntries.js index d9c27d9..8b3ce3c 100644 --- a/src/getCollectionEntries.js +++ b/src/getCollectionEntries.js @@ -18,7 +18,9 @@ function getEntries(type, collection, sortObjectKeys, from=0, to=Infinity) { if (type === 'Object') { let keys = Object.getOwnPropertyNames(collection); - if (typeof sortObjectKeys !== 'undefined') { + if (sortObjectKeys === true) { + keys.sort(); + } else { keys.sort(sortObjectKeys); }