import React from 'react'; import FolderClosedOutlined from '../icons/FolderClosedOutlined'; import FolderOpenOutlined from '../icons/FolderOpenOutlined'; import DirectoryTree from './DirectoryTree'; const METHODS_TO_BIND = ['handleDirectoryClick']; export default class DirectoryTreeNode extends React.Component { constructor() { super(); this.state = { expanded: false }; METHODS_TO_BIND.forEach((method) => { this[method] = this[method].bind(this); }); } getSubTree() { if (this.state.expanded) { return (
); } else { return null; } } handleDirectoryClick() { this.setState({ expanded: !this.state.expanded }); } render() { let classes = `directory-tree__branch directory-tree__branch--depth-${this.props.depth}`; let icon = ; if (this.state.expanded) { icon = ; } return (
{icon} {this.props.directoryName}
{this.getSubTree()}
); } }