<commit_before>import React from 'react';
const { PropTypes } = React;

export default class Component extends React.Component {
  static defaultProps = {
    draw     : function() {},
    realtime : false,
    top      : 0,
    left     : 0
  };

  static propTypes = {
    draw     : PropTypes.func,
    realtime : PropTypes.bool,
    top      : PropTypes.number,
    left     : PropTypes.number
  };

  static contextTypes = {
    ctx      : PropTypes.object,
    realtime : PropTypes.bool
  };

  static childContextTypes = {
    ctx      : PropTypes.object,
    realtime : PropTypes.bool
  };

  getChildContext() {
    const { context, refs, props } = this;
    const ctx = (context && context.ctx) || (refs && refs.canvas && refs.canvas.getContext('2d'));
    const realtime = (context && context.realtime) || props.realtime;
    return { ctx:ctx, realtime:realtime }
  }

  constructor(props) {
    super(props);
    this.requestAnimationFrameCallback = this.requestAnimationFrameCallback.bind(this);
  }

  componentDidMount() {
    this.forceUpdate();
    requestAnimationFrame(this.requestAnimationFrameCallback);
  }

  render() {
    const { props, context } = this;
    requestAnimationFrame(this.requestAnimationFrameCallback);
    if(context.ctx) { return <div key='canvas' {...props}>{props.children}</div>; }
    return <canvas ref='canvas' key='canvas' {...props}>{props.children}</canvas>;
  }

  requestAnimationFrameCallback(time) {
    if(this.previousFrameTime !== time) {
      const { props, context, refs } = this;
      const { draw, top, left } = props;
      const ctx = (context && context.ctx) || (refs && refs.canvas && refs.canvas.getContext('2d'));
      const realtime = (context && context.realtime) || props.realtime;

      let delta = 0;
      if(draw && ctx) {
        if(realtime) {
          requestAnimationFrame(this.requestAnimationFrameCallback);
          if(!this.previousFrameTime) { this.previousFrameTime = time }
          else { delta = time - this.previousFrameTime }
          this.previousFrameTime = time;
        }
        if(top || left) {
          ctx.translate(left, top);
        }<commit_msg>Don't pass internal props to the canvas.<commit_after>import React from 'react';
const { PropTypes } = React;

export default class Component extends React.Component {
  static defaultProps = {
    draw     : function() {},
    realtime : false,
    top      : 0,
    left     : 0
  };

  static propTypes = {
    draw     : PropTypes.func,
    realtime : PropTypes.bool,
    top      : PropTypes.number,
    left     : PropTypes.number
  };

  static contextTypes = {
    ctx      : PropTypes.object,
    realtime : PropTypes.bool
  };

  static childContextTypes = {
    ctx      : PropTypes.object,
    realtime : PropTypes.bool
  };

  getChildContext() {
    const { context, refs, props } = this;
    const ctx = (context && context.ctx) || (refs && refs.canvas && refs.canvas.getContext('2d'));
    const realtime = (context && context.realtime) || props.realtime;
    return { ctx:ctx, realtime:realtime }
  }

  constructor(props) {
    super(props);
    this.requestAnimationFrameCallback = this.requestAnimationFrameCallback.bind(this);
  }

  componentDidMount() {
    this.forceUpdate();
    requestAnimationFrame(this.requestAnimationFrameCallback);
  }

  render() {
    const { props, context } = this;
    const { draw, realtime, top, left, ...other } = props;
    requestAnimationFrame(this.requestAnimationFrameCallback);
    if(context.ctx) { return <div key='canvas' {...other}>{props.children}</div>; }
    return <canvas ref='canvas' key='canvas' {...other}>{props.children}</canvas>;
  }

  requestAnimationFrameCallback(time) {
    if(this.previousFrameTime !== time) {
      const { props, context, refs } = this;
      const { draw, top, left } = props;
      const ctx = (context && context.ctx) || (refs && refs.canvas && refs.canvas.getContext('2d'));
      const realtime = (context && context.realtime) || props.realtime;

      let delta = 0;
      if(draw && ctx) {
        if(realtime) {
          requestAnimationFrame(this.requestAnimationFrameCallback);
          if(!this.previousFrameTime) { this.previousFrameTime = time }
          else { delta = time - this.previousFrameTime }
          this.previousFrameTime = time;
        }
        if(top || left) {
          ctx.translate(left, top);
        }
{'fraction_non_alphanumeric': 0.13204545454545455, 'fraction_numerical': 0.0022727272727272726, 'mean_word_length': 2.8038029386343992, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2618354', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1279, 'n_words': 281}