shlink-web-client/src/index.tsx

38 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-04-02 09:50:59 +03:00
import { createRoot } from 'react-dom/client';
2018-06-03 21:12:40 +03:00
import { Provider } from 'react-redux';
2018-06-03 14:15:52 +03:00
import { BrowserRouter } from 'react-router-dom';
import pack from '../package.json';
import { container } from './container';
import { setUpStore } from './container/store';
2020-08-22 19:32:48 +03:00
import { fixLeafletIcons } from './utils/helpers/leaflet';
import { register as registerServiceWorker } from './serviceWorkerRegistration';
2022-05-02 12:35:05 +03:00
import 'chart.js/auto'; // TODO Import specific ones to reduce bundle size https://react-chartjs-2.js.org/docs/migration-to-v4/#tree-shaking
import 'react-datepicker/dist/react-datepicker.css';
import 'leaflet/dist/leaflet.css';
import './index.scss';
2018-05-13 09:57:47 +03:00
// This overwrites icons used for leaflet maps, fixing some issues caused by webpack while processing the CSS
fixLeafletIcons();
const store = setUpStore(container);
const { App, ScrollToTop, ErrorHandler, appUpdateAvailable } = container;
2018-06-03 21:12:40 +03:00
2022-04-02 09:50:59 +03:00
createRoot(document.getElementById('root')!).render( // eslint-disable-line @typescript-eslint/no-non-null-assertion
2018-06-03 21:12:40 +03:00
<Provider store={store}>
<BrowserRouter basename={pack.homepage}>
2019-03-04 22:40:26 +03:00
<ErrorHandler>
<ScrollToTop>
<App />
</ScrollToTop>
</ErrorHandler>
2018-06-03 21:12:40 +03:00
</BrowserRouter>
</Provider>,
2018-06-03 14:15:52 +03:00
);
// Learn more about service workers: https://cra.link/PWA
registerServiceWorker({
onUpdate() {
store.dispatch(appUpdateAvailable());
},
});