<commit_before>import React, {Suspense} from 'react'
import ReactDOM from 'react-dom'
import {reducer as reducerUtil} from 'tocco-util'
import {
  appFactory,
  notifier,
  errorLogging,
  actionEmitter,
  externalEvents,
  keyDown,
  viewPersistor
} from 'tocco-app-extensions'
import {hot} from 'react-hot-loader/root'
import PropTypes from 'prop-types'

import shortcuts from './shortcuts'
import reducers, {sagas} from './modules/reducers'
const packageName = 'admin'

const LazyLoginGuard = React.lazy(() => import('./components/LoginGuard'))
const LazyAdmin = () => (
  <div>
    <Suspense fallback="">
      <LazyLoginGuard />
    </Suspense>
  </div>
)

const initApp = (id, input, events, publicPath) => {
  window.reactRegistry.setReact(React, ReactDOM)

  const content = <LazyAdmin/>

  const store = appFactory.createStore(reducers, sagas, input, packageName)
  externalEvents.addToStore(store, events)
  actionEmitter.addToStore(store)
  errorLogging.addToStore(store, true, ['console', 'remote', 'notifier'])
  notifier.addToStore(store, true)
  keyDown.addToStore(store, shortcuts)
  viewPersistor.addToStore(store)

  return appFactory.createApp(
    packageName,
    content,
    store,
    {
      input,
      events,
      actions: [],<commit_msg>fix(admin): only call `setReact` if reactRegistry and function exist<commit_after>import React, {Suspense} from 'react'
import ReactDOM from 'react-dom'
import {reducer as reducerUtil} from 'tocco-util'
import {
  appFactory,
  notifier,
  errorLogging,
  actionEmitter,
  externalEvents,
  keyDown,
  viewPersistor
} from 'tocco-app-extensions'
import {hot} from 'react-hot-loader/root'
import PropTypes from 'prop-types'

import shortcuts from './shortcuts'
import reducers, {sagas} from './modules/reducers'
const packageName = 'admin'

const LazyLoginGuard = React.lazy(() => import('./components/LoginGuard'))
const LazyAdmin = () => (
  <div>
    <Suspense fallback="">
      <LazyLoginGuard />
    </Suspense>
  </div>
)

const initApp = (id, input, events, publicPath) => {
  if (window.reactRegistry && window.reactRegistry.setReact) {
    window.reactRegistry.setReact(React, ReactDOM)
  }

  const content = <LazyAdmin/>

  const store = appFactory.createStore(reducers, sagas, input, packageName)
  externalEvents.addToStore(store, events)
  actionEmitter.addToStore(store)
  errorLogging.addToStore(store, true, ['console', 'remote', 'notifier'])
  notifier.addToStore(store, true)
  keyDown.addToStore(store, shortcuts)
  viewPersistor.addToStore(store)

  return appFactory.createApp(
    packageName,
    content,
    store,
    {
      input,
      events,
      actions: [],
{'fraction_non_alphanumeric': 0.12631578947368421, 'fraction_numerical': 0.0, 'mean_word_length': 4.386639676113361, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 21, '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': '4302332', 'n_tokens_mistral': 893, 'n_tokens_neox': 872, 'n_words': 201}