-
Notifications
You must be signed in to change notification settings - Fork 394
/
index.tsx
executable file
·77 lines (61 loc) · 2.08 KB
/
index.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* index.tsx
*
* This is the entry file for the application, only setup and boilerplate
* code.
*/
import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import FontFaceObserver from 'fontfaceobserver';
import * as serviceWorker from 'serviceWorker';
import 'sanitize.css/sanitize.css';
// Initialize languages
import './locales/i18n';
import { App } from 'app';
import { HelmetProvider } from 'react-helmet-async';
import { configureAppStore } from 'store/configureStore';
import { ThemeProvider } from 'styles/theme/ThemeProvider';
// Observe loading of Inter (to remove 'Inter', remove the <link> tag in
// the index.html file and this observer)
const openSansObserver = new FontFaceObserver('Inter', {});
// When Inter is loaded, add a font-family using Inter to the body
openSansObserver.load().then(() => {
document.body.classList.add('fontLoaded');
});
const store = configureAppStore();
const MOUNT_NODE = document.getElementById('root') as HTMLElement;
interface Props {
Component: typeof App;
}
const ConnectedApp = ({ Component }: Props) => (
<Provider store={store}>
<ThemeProvider>
<HelmetProvider>
<React.StrictMode>
<Component />
</React.StrictMode>
</HelmetProvider>
</ThemeProvider>
</Provider>
);
const render = (Component: typeof App) => {
ReactDOM.render(<ConnectedApp Component={Component} />, MOUNT_NODE);
};
if (module.hot) {
// Hot reloadable translation json files and app
// modules.hot.accept does not accept dynamic dependencies,
// have to be constants at compile-time
module.hot.accept(['./app', './locales/i18n'], () => {
ReactDOM.unmountComponentAtNode(MOUNT_NODE);
const App = require('./app').App;
render(App);
});
}
render(App);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();