<commit_before>"use strict";

import React from 'react';
let { PropTypes } = React;

let Video = React.createClass({

  propTypes: {
    src: PropTypes.string.isRequired,
    width: PropTypes.number.isRequired,
    height: PropTypes.number.isRequired,
    currentTimeChanged: PropTypes.func,
    durationChanged: PropTypes.func,
  },

  componentDidMount() {
    let video = React.findDOMNode(this.refs.video);
    video.addEventListener('timeupdate', this.props.currentTimeChanged);
    video.addEventListener('durationchange', this.props.durationChanged);
    video.addEventListener('progress', this.props.onProgress);
    video.addEventListener('ended', this.props.onEnd);
  },

  componentWillUnmount() {
    let video = React.findDOMNode(this.refs.video);
    video.removeEventListener('timeupdate', this.props.currentTimeChanged);
    video.removeEventListener('durationchange', this.props.durationChanged);
    video.removeEventListener('progress', this.props.onProgress);
    video.removeEventListener('ended', this.props.onEnd);
  },

  render() {
    let { src, width, height, currentTimeChanged, durationChanged, ...restProps} = this.props;

    return (<video ref="video" {...restProps}
      width={width} height={height}
      timeupdate={currentTimeChanged}
      durationchange={durationChanged}
    >
      <source src={src} />
    </video>);
  },
});

module.exports = Video;<commit_msg>Implement "shouldComponentUpdate" method to minimise noop render calls.<commit_after>"use strict";

import React from 'react';
let { PropTypes } = React;

module.exports = React.createClass({

  displayName: 'Video',

  propTypes: {
    src: PropTypes.string.isRequired,
    width: PropTypes.number.isRequired,
    height: PropTypes.number.isRequired,
    currentTimeChanged: PropTypes.func,
    durationChanged: PropTypes.func,
  },

  componentDidMount() {
    let video = React.findDOMNode(this.refs.video);
    video.addEventListener('timeupdate', this.props.currentTimeChanged);
    video.addEventListener('durationchange', this.props.durationChanged);
    video.addEventListener('progress', this.props.onProgress);
    video.addEventListener('ended', this.props.onEnd);
  },

  componentWillUnmount() {
    let video = React.findDOMNode(this.refs.video);
    video.removeEventListener('timeupdate', this.props.currentTimeChanged);
    video.removeEventListener('durationchange', this.props.durationChanged);
    video.removeEventListener('progress', this.props.onProgress);
    video.removeEventListener('ended', this.props.onEnd);
  },

  shouldComponentUpdate(nextProps) {
    if (
      this.props.width !== nextProps.width ||
      this.props.height !== nextProps.height ||
      this.props.src !== nextProps.src
    ) {
      return true;
    }
    return false;
  },

  render() {
    const videoProps = {
      autoPlay: this.props.autoPlay,
      width: this.props.width,
      height: this.props.height,
    };

    return (<video ref="video" {...videoProps}>
      <source src={this.props.src} />
    </video>);

  },
});
{'fraction_non_alphanumeric': 0.13708086785009863, 'fraction_numerical': 0.0, 'mean_word_length': 3.9967159277504103, 'pattern_counts': {'":': 0, '<': 9, '<?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': '1252376', 'n_tokens_mistral': 868, 'n_tokens_neox': 860, 'n_words': 151}