<commit_before>import React from 'react'
import PropTypes from 'prop-types';
import { Keyboard, Platform } from 'react-native'

export default class KeyboardAwareTabBarComponent extends React.PureComponent {

  constructor(props) {
    super(props);

    this.state = {
      isVisible: true
    }
  }

  componentWillMount() {
    const keyboardShowEvent = Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow';
    const keyboardHideEvent = Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide';

    this.keyboardWillShowSub = Keyboard.addListener(keyboardShowEvent, this.keyboardWillShow);
    this.keyboardWillHideSub = Keyboard.addListener(keyboardHideEvent, this.keyboardWillHide);
  }

  componentWillUnmount() {
    this.keyboardWillShowSub.remove();
    this.keyboardWillHideSub.remove();
  }

  keyboardWillShow = (event) => {
    this.setState({
      isVisible: false
    })
  }

  keyboardWillHide = (event) => {
    this.setState({
      isVisible: true
    })
  }

  render() {
    const { TabBarComponent, ...componentProps } = this.props;
    const { isVisible } = this.state;

    return isVisible
      ? <TabBarComponent {...componentProps} />
      : null
  }
}

KeyboardAwareTabBarComponent.propTypes = {
  TabBarComponent: PropTypes.node.isRequired,
};
<commit_msg>Allow passing a stateless component as TabBarComponent (#35)<commit_after>import React from 'react'
import PropTypes from 'prop-types';
import { Keyboard, Platform } from 'react-native'

export default class KeyboardAwareTabBarComponent extends React.PureComponent {

  constructor(props) {
    super(props);

    this.state = {
      isVisible: true
    }
  }

  componentWillMount() {
    const keyboardShowEvent = Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow';
    const keyboardHideEvent = Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide';

    this.keyboardWillShowSub = Keyboard.addListener(keyboardShowEvent, this.keyboardWillShow);
    this.keyboardWillHideSub = Keyboard.addListener(keyboardHideEvent, this.keyboardWillHide);
  }

  componentWillUnmount() {
    this.keyboardWillShowSub.remove();
    this.keyboardWillHideSub.remove();
  }

  keyboardWillShow = (event) => {
    this.setState({
      isVisible: false
    })
  }

  keyboardWillHide = (event) => {
    this.setState({
      isVisible: true
    })
  }

  render() {
    const { TabBarComponent, ...componentProps } = this.props;
    const { isVisible } = this.state;

    return isVisible
      ? <TabBarComponent {...componentProps} />
      : null
  }
}

KeyboardAwareTabBarComponent.propTypes = {
  TabBarComponent: PropTypes.oneOfType([ PropTypes.node, PropTypes.func ]).isRequired,
};

{'fraction_non_alphanumeric': 0.11843079200592153, 'fraction_numerical': 0.0007401924500370096, 'mean_word_length': 3.717277486910995, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '1991384', 'n_tokens_mistral': 830, 'n_tokens_neox': 824, 'n_words': 154}