-
Notifications
You must be signed in to change notification settings - Fork 324
/
Copy pathmain.tsx
47 lines (37 loc) · 1.52 KB
/
main.tsx
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
// Import Sentry earliest to capture exceptions
import 'bootstrapping/sentry';
// core-js has issues with Promise feature detection on Edge, and hence
// polyfills Promise incorrectly. Importing this polyfill directly resolves that.
// This is necessary as PersistGate used in ./App uses `Promise.prototype.finally`.
// See: https://github.com/zloirock/core-js/issues/579#issuecomment-504325213
import 'core-js/es/promise/finally';
import { createRoot } from 'react-dom/client';
import ReactModal from 'react-modal';
import configureStore from 'bootstrapping/configure-store';
import subscribeOnlineEvents from 'bootstrapping/subscribeOnlineEvents';
import { initializeMamoto } from 'bootstrapping/matomo';
import registerServiceWorker from 'bootstrapping/service-worker-manager';
import 'styles/main.scss';
import App from './App';
const { store, persistor } = configureStore();
subscribeOnlineEvents(store);
// Initialize ReactModal
ReactModal.setAppElement('#app');
const container = document.getElementById('app');
if (!container) {
throw new Error('#app element not found');
}
const root = createRoot(container);
root.render(<App store={store} persistor={persistor} />);
if (
((NUSMODS_ENV === 'preview' || NUSMODS_ENV === 'staging' || NUSMODS_ENV === 'production') &&
'serviceWorker' in navigator &&
window.location.protocol === 'https:') ||
// Allow us to force service worker to be enabled for debugging
DEBUG_SERVICE_WORKER
) {
registerServiceWorker(store);
}
if (NUSMODS_ENV === 'production') {
initializeMamoto();
}