<commit_before>// @flow
import React from 'react'

type TabBarProps = {
  name: string,
  children?: React.Children,
  selectedIndex: number,
  onSelect: () => { index: number, name: string }
}

const TabBar = ({ name, children, selectedIndex, onSelect }: TabBarProps) => {
  const handleSelect = (data) => () => onSelect(data)
  return (
    <div>
      { React.Children.map(children, (child, index) =>
        React.cloneElement(child, {
          onSelectTab: handleSelect({ name, index }),
          selected: index === selectedIndex,
        })
      ) }
    </div>
  )
}

class ConnectedTabBar extends React.Component {
  props: TabBarProps & {
    onMount: () => number,
    selectIndex: number,
  }

  static defaultProps = {
    selectIndex: 0,
    onMount: () => {},
  }

  componentDidMount() {
    this.props.onMount(this.props.selectIndex)
  }

  render() {
    return (
      <TabBar
        name={ this.props.name }
        index={ 1 }
        onSelect={ this.props.onSelect }
        selectedIndex={ this.props.selectIndex }
      >
        { this.props.children }
      </TabBar>
    )
  }
}

export default ConnectedTabBar
<commit_msg>Flow Fixes<commit_after>// @flow
import React from 'react'

type TabBarProps = {
  name: string,
  children?: React.Children,
  selectedIndex: number,
  onSelect: ({ index: number, name: string }) => void
}

const TabBar = ({ name, children, selectedIndex, onSelect }: TabBarProps) => {
  const handleSelect = data => () => onSelect(data)
  return (
    <div>
      { React.Children.map(children, (child, index: number) =>
        React.cloneElement(child, {
          onSelectTab: handleSelect({ name, index }),
          selected: index === selectedIndex,
        }),
      ) }
    </div>
  )
}

class ConnectedTabBar extends React.Component {
  props: TabBarProps & {
    onMount: (index: number) => void,
    selectIndex: number,
  }

  static defaultProps = {
    selectIndex: 0,
    onMount: () => {},
  }

  componentDidMount() {
    this.props.onMount(this.props.selectIndex)
  }

  render() {
    return (
      <TabBar
        name={ this.props.name }
        index={ 1 }
        onSelect={ this.props.onSelect }
        selectedIndex={ this.props.selectIndex }
      >
        { this.props.children }
      </TabBar>
    )
  }
}

export default ConnectedTabBar

{'fraction_non_alphanumeric': 0.1389247311827957, 'fraction_numerical': 0.0017204301075268817, 'mean_word_length': 2.503012048192771, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, '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': '6148445', 'n_tokens_mistral': 739, 'n_tokens_neox': 732, 'n_words': 159}