<commit_before>import React from "react/addons";
import Util from "../helpers/Util";

var SectionComponent = React.createClass({
  "displayName": "SectionComponent",

  propTypes: {
    active: React.PropTypes.bool,
    children: React.PropTypes.node,
    id: React.PropTypes.string.isRequired,
    onActive: React.PropTypes.func
  },

  getDefaultProps: function () {
    return {
      active: false,
      onActive: Util.noop
    };
  },

  componentDidMount: function () {
    this.triggerCallbacks();
  },

  componentDidUpdate: function () {
    this.triggerCallbacks();
  },

  triggerCallbacks: function () {
    var {active, onActive} = this.props;

    if (active) {
      onActive();
    }
  },

  render: function () {
    var {children, active} = this.props;

    if (!active) {
      return null;
    }

    return (
      <section>
        {children}
      </section>
    );
  }
});<commit_msg>Fix section component callback handling<commit_after>import React from "react/addons";
import Util from "../helpers/Util";

var SectionComponent = React.createClass({
  "displayName": "SectionComponent",

  propTypes: {
    active: React.PropTypes.bool,
    children: React.PropTypes.node,
    id: React.PropTypes.string.isRequired,
    onActive: React.PropTypes.func
  },

  getDefaultProps: function () {
    return {
      active: false,
      onActive: Util.noop
    };
  },

  getInitialState: function () {
    return {
      activeStateChanged: true
    };
  },

  componentWillReceiveProps: function (nextProps) {
    this.setState({
      activeStateChanged: nextProps.active !== this.props.active
    });
  },

  componentDidMount: function () {
    this.triggerCallbacks();
  },

  componentDidUpdate: function () {
    this.triggerCallbacks();
  },

  triggerCallbacks: function () {
    var {activeStateChanged} = this.state;
    var {active, onActive} = this.props;

    if (activeStateChanged && active) {
      onActive();
    }
  },

  render: function () {
    var {children, active} = this.props;

    if (!active) {
      return null;
    }

    return (
      <section>
        {children}
      </section>
    );
  }
});
{'fraction_non_alphanumeric': 0.13395348837209303, 'fraction_numerical': 0.0, 'mean_word_length': 2.70223752151463, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, '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': '960829', 'n_tokens_mistral': 670, 'n_tokens_neox': 649, 'n_words': 136}