<commit_before>import * as React from 'react';
import Component from '../../organisms/component';

const isMap = x => x && x.constructor && x.constructor.name === 'Map';
const isComponent = x => x && (x.id && x.path && x.entry);

const getNested = (tree, path) => {
	const parts = path.split('/');
	let temp = tree;
	while (isMap(temp)) {
		if (temp.has(parts[0])) {
			temp = temp.get(parts.shift());
		} else {
			break;
		}
	}
	return temp;
};

export default function ComponentRenderer({tree, id}) {
	const components = getNested(tree, id);

	return (
		<div>
			{isComponent(components) ?
				(<Component component={components} />) :
				[...components.values()].map(component => {
					return isComponent(component) ?
						(<Component component={component} />) :
						null
				})
			}
		</div>
	);
}

ComponentRenderer.propTypes = {
	tree: React.PropTypes.instanceOf(Map),
	id: React.PropTypes.string
};

ComponentRenderer.defaultProps = {
	tree: new Map(),
	id: ''
};
<commit_msg>fix(component-renderer): add missing react key prop to list<commit_after>import * as React from 'react';
import Component from '../../organisms/component';

const isMap = x => x && x.constructor && x.constructor.name === 'Map';
const isComponent = x => x && (x.id && x.path && x.entry);

const getNested = (tree, path) => {
	const parts = path.split('/');
	let temp = tree;
	while (isMap(temp)) {
		if (temp.has(parts[0])) {
			temp = temp.get(parts.shift());
		} else {
			break;
		}
	}
	return temp;
};

export default function ComponentRenderer({tree, id}) {
	const components = getNested(tree, id);

	return (
		<div>
			{isComponent(components) ?
				(<Component component={components} />) :
				[...components.values()].map((component, index) => {
					return isComponent(component) ?
						(<Component key={index} component={component} />) :
						null
				})
			}
		</div>
	);
}

ComponentRenderer.propTypes = {
	tree: React.PropTypes.instanceOf(Map),
	id: React.PropTypes.string
};

ComponentRenderer.defaultProps = {
	tree: new Map(),
	id: ''
};

{'fraction_non_alphanumeric': 0.18190709046454767, 'fraction_numerical': 0.0009779951100244498, 'mean_word_length': 3.5165562913907285, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6643050', 'n_tokens_mistral': 750, 'n_tokens_neox': 672, 'n_words': 157}