<commit_before>import React, { Component } from 'react';
import { find } from 'underscore';

import './style.scss';

export default class RoomSidebar extends Component {
  constructor(props) {
    super(props);

    const children = React.Children.toArray(props.children).map(item => item.type.name);

    this.state = {
      activeTab: props.activeTab || children[0],
      availableTabs: children
    };

    this.setActiveTab.bind(this);
  }

  setActiveTab(name) {
    this.setState({ activeTab: name });
  }

  getComponent(name) {
    const children = React.Children.toArray(this.props.children);
    return find(children, child => child.type.name === name);
  }

  render() {
    const activeComponent = this.getComponent(this.state.activeTab);
    const children = this.state.availableTabs;
    const hasMultipleTabs = tabs.length > 1;
    const tabs = children.map((child) => {
      return (
        <div className="tab" key={ child } onClick={() => { this.setActiveTab(child); }}>
          { child }
        </div>
      );
    });

    if (!hasMultipleTabs) {
      return (
        <div className="room-sidebar">
          { activeComponent }<commit_msg>fix(room): use tabs after it's been defined<commit_after>import React, { Component } from 'react';
import { find } from 'underscore';

import './style.scss';

export default class RoomSidebar extends Component {
  constructor(props) {
    super(props);

    const children = React.Children.toArray(props.children).map(item => item.type.name);

    this.state = {
      activeTab: props.activeTab || children[0],
      availableTabs: children
    };

    this.setActiveTab.bind(this);
  }

  setActiveTab(name) {
    this.setState({ activeTab: name });
  }

  getComponent(name) {
    const children = React.Children.toArray(this.props.children);
    return find(children, child => child.type.name === name);
  }

  render() {
    const activeComponent = this.getComponent(this.state.activeTab);
    const children = this.state.availableTabs;
    const tabs = children.map((child) => {
      return (
        <div className="tab" key={ child } onClick={() => { this.setActiveTab(child); }}>
          { child }
        </div>
      );
    });
    const hasMultipleTabs = tabs.length > 1;

    if (!hasMultipleTabs) {
      return (
        <div className="room-sidebar">
          { activeComponent }
{'fraction_non_alphanumeric': 0.14104729729729729, 'fraction_numerical': 0.0016891891891891893, 'mean_word_length': 2.954924874791319, 'pattern_counts': {'":': 0, '<': 9, '<?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': '968668', 'n_tokens_mistral': 717, 'n_tokens_neox': 696, 'n_words': 150}