-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathshared.entry.tsx
More file actions
68 lines (54 loc) · 1.85 KB
/
shared.entry.tsx
File metadata and controls
68 lines (54 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* ELASTICSEARCH CONFIDENTIAL
* __________________
*
* Copyright Elasticsearch B.V. All rights reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Elasticsearch B.V. and its suppliers, if any.
* The intellectual and technical concepts contained herein
* are proprietary to Elasticsearch B.V. and its suppliers and
* may be covered by U.S. and Foreign Patents, patents in
* process, and are protected by trade secret or copyright
* law. Dissemination of this information or reproduction of
* this material is strictly forbidden unless prior written
* permission is obtained from Elasticsearch B.V.
*/
import { noop } from 'lodash'
import React from 'react'
import ReactDOM from 'react-dom'
import { UnhandledApplicationLoadError } from './components/ApplicationLoadError'
import { setInitialTheme, trackColorSchemePreference } from './lib/theme'
import { pullConfigFromHtml } from './lib/configStore'
import { setupGoogleTracking } from './apps/userconsole/lib/googleTracking'
import { configureStore } from './store/_setup'
export function sharedEntryPoint(
App,
{
initHook = noop,
}: {
initHook?: () => void
} = {},
) {
const appRoot = document.getElementById(`app-root`)
try {
setInitialTheme()
const config = pullConfigFromHtml()
const store = configureStore({ config })
if (config.GOOGLE_ANALYTICS_TRACKING_ID) {
setupGoogleTracking(config.GOOGLE_ANALYTICS_TRACKING_ID)
}
trackColorSchemePreference(store)
initHook()
render({ App, appRoot, store })
} catch (err) {
renderError({ appRoot, err })
}
}
function render({ App, appRoot, store }) {
ReactDOM.render(<App store={store} />, appRoot)
}
function renderError({ appRoot, err }) {
const unhandledError = <UnhandledApplicationLoadError error={err} />
ReactDOM.render(unhandledError, appRoot)
}