import * as ReactDOM from 'react-dom' ; import * as React from 'react' ; import { Provider } from 'mobx-react' ; import { Layout } from './layout' ; import { initState , RenderOptions } from '../models/state_model' ; import { setupRouter } from '../config/router' ; import { buildBridge } from '../../bridge' ; import { ProxyStore } from '../models/proxy_store' ; const state = initState ( ) ; export async function renderLuis ( options = { } ) { let root = document . querySelector ( options . root || '#react-root' ) ; if ( ! root ) { root = document . createElement ( 'div' ) ; root . id = options . root || 'react-root' ; document . body . appendChild ( root ) ; } ReactDOM . render ( < Luis options = { options } / > , root ) ; } type Props = { options : RenderOptions ; } ; export const Luis = ( { options = { } } ) => { state . renderOptions = options ; buildBridge ( options . report , options . snapshots ) ; options . loadTests ( ) ; if ( options . proxies ) { ProxyStore . init ( options . proxies ) ; } setupRouter ( state ) ; state . liveRoot . version ++ ; return ( < Provider state = { state } > < Layout localStorage = { localStorage } /> < /Provider>); } ;