forked from codesandbox/codesandbox-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (29 loc) · 882 Bytes
/
index.js
File metadata and controls
33 lines (29 loc) · 882 Bytes
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
// @flow
import React from 'react';
import { render } from 'react-dom';
import requirePolyfills from '@codesandbox/common/lib/load-dynamic-polyfills';
import 'normalize.css';
import '@codesandbox/common/lib/global.css';
import track, { identify } from '@codesandbox/common/lib/utils/analytics';
import App from './components/App';
try {
identify('signed_in', Boolean(localStorage.jwt));
} catch (e) {
/* ignore error */
}
document.addEventListener('click', () => {
track('Embed Interaction');
});
requirePolyfills().then(() => {
function renderApp(Component) {
render(<Component />, document.getElementById('root'));
}
if (module.hot) {
// $FlowIssue
module.hot.accept('./components/App', () => {
const NextApp = require('./components/App').default; // eslint-disable-line global-require
renderApp(NextApp);
});
}
renderApp(App);
});