import React, { Children } from 'react';
import MultiSelect, { Selectable } from '../../../dist/es6';
import './index.css';
export default class NestedLists extends React.Component {
constructor(props) {
super(props);
this.state = { selection: new Set };
this.onSelectionChange = this.onSelectionChange.bind(this);
this._renderList = this._renderList.bind(this);
}
onSelectionChange(selection) {
this.state.selection !== selection && this.setState({ selection });
console.log(selection);
}
_renderList({ name, entries = [] }, root = true) {
const selectable = {name};
if (entries.length === 0) {
return selectable;
}
const multiselect = (
{entries.map(e => this._renderList(e, false))}
);
return root ? multiselect : [
selectable,
{multiselect}
];
}
render() {
return this._renderList(this.props.data);
}
};