<commit_before>//
// MDL style Spinner component.
//
// - @see [MDL Spinner](http://www.getmdl.io/components/index.html#loading-section/spinner)
// - [Props](#props)
// - [Defaults](#defaults)
// - [Built-in builders](#builders)
//
// Created by ywu on 15/8/14.
//

const React = require('react-native');

const {
  Component,
  View,
  PropTypes,
  Animated,
} = React;

const MKColor = require('../MKColor');
const {getTheme} = require('../theme');
const utils = require('../utils');

// controlling speed of rotation: percent to degree
const spinnerRotationInterpolate = {
  inputRange: [
    0, .125, .25, .375, .5, .625, .75, .875, 1,
  ],
  outputRange: [
    '0deg', '45deg', '90deg', '135deg', '180deg', '225deg', '270deg', '315deg', '360deg',
  ],
};

// default stroke colors
const defaultStrokeColors = [
  'rgb(66,165,245)',  //palette-blue-400
  'rgb(244,67,54)',   //palette-red-500
  'rgb(253,216,53)',  //palette-yellow-600
  'rgb(76,175,80)',   //palette-green-500
];


//
// ## <section id='Spinner'>Spinner</section>
// The default `Spinner` component.
//
class Spinner extends Component {
  constructor(props) {
    super(props);
    this.state = {
      strokeColor: defaultStrokeColors[0],
      dimen: {},
    };
    this._strokeColorIndex = 0;
    this._animatedContainerAngle = new Animated.Value(0);
    this._animatedArcAngle = new Animated.Value(0);
  }

  componentDidMount() {
    requestAnimationFrame(() => {
      const container = this.refs.container.refs.node;  // un-box animated view
      container.measure((left, top, width, height) => {
        this.setState({dimen: {width, height}}, () => this._aniUpdateSpinner());
      });<commit_msg>Spinner component was throwing an error if it was created and delete quickly<commit_after>//
// MDL style Spinner component.
//
// - @see [MDL Spinner](http://www.getmdl.io/components/index.html#loading-section/spinner)
// - [Props](#props)
// - [Defaults](#defaults)
// - [Built-in builders](#builders)
//
// Created by ywu on 15/8/14.
//

const React = require('react-native');

const {
  Component,
  View,
  PropTypes,
  Animated,
} = React;

const MKColor = require('../MKColor');
const {getTheme} = require('../theme');
const utils = require('../utils');

// controlling speed of rotation: percent to degree
const spinnerRotationInterpolate = {
  inputRange: [
    0, .125, .25, .375, .5, .625, .75, .875, 1,
  ],
  outputRange: [
    '0deg', '45deg', '90deg', '135deg', '180deg', '225deg', '270deg', '315deg', '360deg',
  ],
};

// default stroke colors
const defaultStrokeColors = [
  'rgb(66,165,245)',  //palette-blue-400
  'rgb(244,67,54)',   //palette-red-500
  'rgb(253,216,53)',  //palette-yellow-600
  'rgb(76,175,80)',   //palette-green-500
];


//
// ## <section id='Spinner'>Spinner</section>
// The default `Spinner` component.
//
class Spinner extends Component {
  constructor(props) {
    super(props);
    this.state = {
      strokeColor: defaultStrokeColors[0],
      dimen: {},
    };
    this._strokeColorIndex = 0;
    this._animatedContainerAngle = new Animated.Value(0);
    this._animatedArcAngle = new Animated.Value(0);
  }

  componentDidMount() {
    requestAnimationFrame(() => {
      if (this.refs.container == null) {
+        return;
+     }
      const container = this.refs.container.refs.node;  // un-box animated view
      container.measure((left, top, width, height) => {
        this.setState({dimen: {width, height}}, () => this._aniUpdateSpinner());
      });
{'fraction_non_alphanumeric': 0.18726699168339547, 'fraction_numerical': 0.05334098078577574, 'mean_word_length': 3.217654171704958, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5276086', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1183, 'n_words': 250}