<commit_before>import * as React from 'react';
import classNames from 'classnames';

// http://stackoverflow.com/questions/29891458/webpack-require-every-file-in-directory
// const svgRequire = (require as any).context('./style/assets', false, /\.svg$/);
// svgRequire.keys().forEach(key => svgRequire(key));

export interface IconPropType {
  type: string;
  className?: string;
  style?: React.CSSProperties;
  size?: 'xxs' | 'xs' | 'sm' | 'md' | 'lg';
}

export default class Icon extends React.Component<IconPropType, any> {
  renderSvg = () => {
    let svg;
    try {
      svg = require(`./style/assets/${this.props.type}.svg`);
    } finally {
      return svg;
    }
  }
  render() {
    const { type, className, style, size = 'md' } = this.props;
    let xlinkHref = this.renderSvg();
    let outerIcon;
    if (!xlinkHref) {
      outerIcon = true;
      xlinkHref = type;
    } else {
      xlinkHref = `#${type}`;
    }
    const iconClassName = classNames({
      'am-icon': true,
      [`am-icon-${outerIcon ? type.substr(1) : type}`]: true,
      [`am-icon-${size}`]: true,
      [className as string]: !!className,
    });
    return <svg className={iconClassName} style={style}>
      <use xlinkHref={xlinkHref} />
    </svg>;
  }
}
<commit_msg>fix(icon): avoid warning in console. close #895<commit_after>import * as React from 'react';
import classNames from 'classnames';

// http://stackoverflow.com/questions/29891458/webpack-require-every-file-in-directory
// const svgRequire = (require as any).context('./style/assets', false, /\.svg$/);
// svgRequire.keys().forEach(key => svgRequire(key));

export interface IconPropType {
  type: string;
  className?: string;
  style?: React.CSSProperties;
  size?: 'xxs' | 'xs' | 'sm' | 'md' | 'lg';
}

export default class Icon extends React.Component<IconPropType, any> {
  renderSvg = () => {
    let svg;
    try {
      svg = require(`./style/assets/${this.props.type}.svg`);
    } catch (e) {

    } finally {
      return svg;
    }
  }
  render() {
    const { type, className, style, size = 'md' } = this.props;
    let xlinkHref = this.renderSvg();
    let outerIcon;
    if (!xlinkHref) {
      outerIcon = true;
      xlinkHref = type;
    } else {
      xlinkHref = `#${type}`;
    }
    const iconClassName = classNames({
      'am-icon': true,
      [`am-icon-${outerIcon ? type.substr(1) : type}`]: true,
      [`am-icon-${size}`]: true,
      [className as string]: !!className,
    });
    return <svg className={iconClassName} style={style}>
      <use xlinkHref={xlinkHref} />
    </svg>;
  }
}

{'fraction_non_alphanumeric': 0.17642497091896084, 'fraction_numerical': 0.0081426909654905, 'mean_word_length': 2.9509954058192958, 'pattern_counts': {'":': 0, '<': 11, '<?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': '6248177', 'n_tokens_mistral': 887, 'n_tokens_neox': 882, 'n_words': 196}