<commit_before>import debounce from 'lodash.debounce'
import React, {PropTypes} from 'react'
import ReactInstanceHandles from 'react/lib/ReactInstanceHandles'
import ReactUpdates from 'react/lib/ReactUpdates'
import ReactElement from 'react/lib/ReactElement'
import instantiateReactComponent from 'react/lib/instantiateReactComponent'
import invariant from 'invariant'

import inject from './inject'
import {renderComponents} from './render-components'

inject()

export function render (element, renderPasses) {
  invariant(
    ReactElement.isValidElement(element),
    'render(): You must pass a valid ReactElement.'
  )

  const wrapperComponent = React.createClass({
    childContextTypes: {
      specularQueueUpdate: PropTypes.func
    },
    componentWillMount () {
      this.specularQueueUpdate = debounce(() => renderComponents(this, renderPasses))
    },
    getChildContext () {
      return {
        specularQueueUpdate: this.specularQueueUpdate
      }
    },
    render () {
      return element
    }
  })

  const id = ReactInstanceHandles.createReactRootID()
  const transaction = ReactUpdates.ReactReconcileTransaction.getPooled()
  const component = instantiateReactComponent(React.createElement(wrapperComponent))

  transaction.perform(() =>
    component.mountComponent(id, transaction, {})
  )

  renderComponents(component._instance, renderPasses)

  return component._instance
}
<commit_msg>Use ReactReconciler to mount the root component when rendering<commit_after>import debounce from 'lodash.debounce'
import ReactInstanceHandles from 'react/lib/ReactInstanceHandles'
import ReactUpdates from 'react/lib/ReactUpdates'
import ReactReconciler from 'react/lib/ReactReconciler'
import ReactElement from 'react/lib/ReactElement'
import instantiateReactComponent from 'react/lib/instantiateReactComponent'
import invariant from 'invariant'

import inject from './inject'
import {renderComponents} from './render-components'

inject()

export function render (element, renderPasses) {
  invariant(
    ReactElement.isValidElement(element),
    'render(): You must pass a valid ReactElement.'
  )

  const id = ReactInstanceHandles.createReactRootID()
  const transaction = ReactUpdates.ReactReconcileTransaction.getPooled()
  const component = instantiateReactComponent(element)

  transaction.perform(() =>
    ReactReconciler.mountComponent(component, id, transaction, {
      specularQueueUpdate: debounce(() => renderComponents(component._instance, renderPasses))
    })
  )

  renderComponents(component._instance, renderPasses)

  return component._instance
}

{'fraction_non_alphanumeric': 0.09069857197993053, 'fraction_numerical': 0.0, 'mean_word_length': 5.215827338129497, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1859242', 'n_tokens_mistral': 699, 'n_tokens_neox': 704, 'n_words': 166}