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

import { callIfDefined } from './shared/utils';

import { isPage, isRotate } from './shared/propTypes';

export default class PageSVG extends Component {
  /**
   * Called when a page is rendered successfully.
   */
  onRenderSuccess = () => {
    this.renderer = null;

    callIfDefined(this.props.onRenderSuccess);
  }

  /**
   * Called when a page fails to render.
   */
  onRenderError = (error) => {
    if (error === 'cancelled') {
      return;
    }

    callIfDefined(
      this.props.onRenderError,
      error,
    );
  }

  get viewport() {
    const { page, rotate, scale } = this.props;

    return page.getViewport(scale, rotate);
  }

  drawPageOnContainer = (element) => {
    if (!element) {
      return null;
    }

    const { page } = this.props;
    const { viewport } = this;

    this.renderer = page.getOperatorList();

    return this.renderer
      .then((operatorList) => {
        const svgGfx = new PDFJS.SVGGraphics(page.commonObjs, page.objs);
        this.renderer = svgGfx.getSVG(operatorList, viewport)
          .then((svg) => {
            svg.style.maxWidth = '100%';
            svg.style.height = 'auto';
            element.appendChild(svg);
          })
          .catch(this.onRenderError);
      })
      .catch(this.onRenderError);
  }

  render() {
    return (
      <div
        className="react-pdf__Page__svg"
        style={{
          display: 'block',
          backgroundColor: 'white',
        }}
        ref={this.drawPageOnContainer}
      />
    );
  }
}

PageSVG.propTypes = {
  onRenderError: PropTypes.func,
  onRenderSuccess: PropTypes.func,
  page: isPage.isRequired,
  rotate: isRotate,
  scale: PropTypes.number,
};
<commit_msg>Fix PageSVG not calling onRenderSuccess when rendered page<commit_after>import React, { Component } from 'react';
import PropTypes from 'prop-types';

import { callIfDefined } from './shared/utils';

import { isPage, isRotate } from './shared/propTypes';

export default class PageSVG extends Component {
  /**
   * Called when a page is rendered successfully.
   */
  onRenderSuccess = () => {
    this.renderer = null;

    callIfDefined(this.props.onRenderSuccess);
  }

  /**
   * Called when a page fails to render.
   */
  onRenderError = (error) => {
    if (error === 'cancelled') {
      return;
    }

    callIfDefined(
      this.props.onRenderError,
      error,
    );
  }

  get viewport() {
    const { page, rotate, scale } = this.props;

    return page.getViewport(scale, rotate);
  }

  drawPageOnContainer = (element) => {
    if (!element) {
      return null;
    }

    const { page } = this.props;
    const { viewport } = this;

    this.renderer = page.getOperatorList();

    return this.renderer
      .then((operatorList) => {
        const svgGfx = new PDFJS.SVGGraphics(page.commonObjs, page.objs);
        this.renderer = svgGfx.getSVG(operatorList, viewport)
          .then((svg) => {
            svg.style.maxWidth = '100%';
            svg.style.height = 'auto';
            element.appendChild(svg);
            this.onRenderSuccess();
          })
          .catch(this.onRenderError);
      })
      .catch(this.onRenderError);
  }

  render() {
    return (
      <div
        className="react-pdf__Page__svg"
        style={{
          display: 'block',
          backgroundColor: 'white',
        }}
        ref={this.drawPageOnContainer}
      />
    );
  }
}

PageSVG.propTypes = {
  onRenderError: PropTypes.func,
  onRenderSuccess: PropTypes.func,
  page: isPage.isRequired,
  rotate: isRotate,
  scale: PropTypes.number,
};

{'fraction_non_alphanumeric': 0.13158613158613158, 'fraction_numerical': 0.001638001638001638, 'mean_word_length': 2.32486388384755, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '1303976', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1157, 'n_words': 238}