From 1b0669bdc059915b69c7120c5141bce71a59d40a Mon Sep 17 00:00:00 2001 From: Leon Aves Date: Sun, 28 Feb 2016 01:23:38 +0000 Subject: [PATCH] Fixes issue #34 (Does not correctly handle immutable objects when hideRoot is false) --- src/JSONIterableNode.js | 2 +- src/index.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/JSONIterableNode.js b/src/JSONIterableNode.js index d670b8b..2f1f4f8 100644 --- a/src/JSONIterableNode.js +++ b/src/JSONIterableNode.js @@ -25,7 +25,7 @@ function renderItemString({ // Returns the child nodes for each entry in iterable. // If we have generated them previously we return from cache; otherwise we create them. -function getChildNodes({ +export function getChildNodes({ data, getItemString, labelRenderer, diff --git a/src/index.js b/src/index.js index e8b567e..d5c7dd0 100644 --- a/src/index.js +++ b/src/index.js @@ -5,8 +5,10 @@ import React from 'react'; import grabNode from './grab-node'; +import objType from './obj-type'; import solarized from './themes/solarized'; -import {getChildNodes} from './JSONObjectNode'; +import { getChildNodes as getObjectChildNodes } from './JSONObjectNode'; +import { getChildNodes as getIterableChildNodes } from './JSONIterableNode'; const styles = { tree: { @@ -77,6 +79,7 @@ export default class JSONTree extends React.Component { } = this.props; let nodeToRender; + let getChildNodes = objType(value) === 'Iterable' ? getIterableChildNodes : getObjectChildNodes; if (!this.props.hideRoot) { nodeToRender = grabNode({