From b5a878df876ee12f7a5875590d25a43fb1e673d6 Mon Sep 17 00:00:00 2001 From: Jose Garcia Date: Sun, 23 Aug 2015 19:26:38 -0400 Subject: [PATCH] Fix for issue #83 - JSONObjectNode#getChildNodes: Cannot read property '...' of null (previousData) --- src/react/JSONTree/JSONArrayNode.js | 2 +- src/react/JSONTree/JSONIterableNode.js | 2 +- src/react/JSONTree/JSONObjectNode.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/react/JSONTree/JSONArrayNode.js b/src/react/JSONTree/JSONArrayNode.js index b7618735..01012c0b 100644 --- a/src/react/JSONTree/JSONArrayNode.js +++ b/src/react/JSONTree/JSONArrayNode.js @@ -58,7 +58,7 @@ export default class JSONArrayNode extends React.Component { let childNodes = []; this.props.data.forEach((element, idx) => { let prevData; - if (typeof this.props.previousData !== 'undefined') { + if (typeof this.props.previousData !== 'undefined' && this.props.previousData !== null) { prevData = this.props.previousData[idx]; } const node = grabNode(idx, element, prevData, this.props.theme); diff --git a/src/react/JSONTree/JSONIterableNode.js b/src/react/JSONTree/JSONIterableNode.js index 280e9918..34038b37 100644 --- a/src/react/JSONTree/JSONIterableNode.js +++ b/src/react/JSONTree/JSONIterableNode.js @@ -67,7 +67,7 @@ export default class JSONIterableNode extends React.Component { } let prevData; - if (typeof this.props.previousData !== 'undefined') { + if (typeof this.props.previousData !== 'undefined' && this.props.previousData !== null) { prevData = this.props.previousData[key]; } const node = grabNode(key, value, prevData, this.props.theme); diff --git a/src/react/JSONTree/JSONObjectNode.js b/src/react/JSONTree/JSONObjectNode.js index a829a634..1b79659c 100644 --- a/src/react/JSONTree/JSONObjectNode.js +++ b/src/react/JSONTree/JSONObjectNode.js @@ -58,7 +58,7 @@ export default class JSONObjectNode extends React.Component { for (let k in obj) { if (obj.hasOwnProperty(k)) { let prevData; - if (typeof this.props.previousData !== 'undefined') { + if (typeof this.props.previousData !== 'undefined' && this.props.previousData !== null) { prevData = this.props.previousData[k]; } const node = grabNode(k, obj[k], prevData, this.props.theme);