1
0
mirror of https://github.com/uetchy/namae.git synced 2025-07-03 06:40:04 +09:00
namae/web/src/index.tsx

45 lines
1.2 KiB
TypeScript
Raw Normal View History

2019-09-17 14:30:26 +09:00
import React from 'react';
import ReactDOM from 'react-dom';
2020-03-06 00:35:37 +09:00
import {Router} from 'react-router-dom';
2020-03-26 20:22:06 +09:00
import {StoreProvider, createStore} from 'easy-peasy';
import {createBrowserHistory} from 'history';
2019-09-17 14:30:26 +09:00
import App from './App';
import * as serviceWorker from './serviceWorker';
import {FullScreenSuspense} from './util/suspense';
2020-03-26 20:22:06 +09:00
import {wrapHistoryWithGA, initSentry} from './util/analytics';
import {initCrisp} from './util/crip';
2020-03-26 20:22:06 +09:00
import {storeModel} from './store';
2019-09-17 14:30:26 +09:00
import './util/i18n';
2019-08-03 13:36:29 +09:00
2019-09-24 13:55:07 +09:00
initSentry();
initCrisp();
2019-09-24 13:55:07 +09:00
2020-03-26 20:22:06 +09:00
const store = createStore(storeModel);
const history = wrapHistoryWithGA(createBrowserHistory());
history.listen(() => {
// reset stats counter
store.getActions().stats.reset();
});
2020-03-06 00:35:37 +09:00
2019-09-24 13:55:07 +09:00
ReactDOM.render(
2020-03-26 20:22:06 +09:00
<StoreProvider store={store}>
<FullScreenSuspense>
<Router history={history}>
<App />
</Router>
</FullScreenSuspense>
</StoreProvider>,
2019-09-24 13:55:07 +09:00
document.getElementById('root'),
2019-09-17 14:30:26 +09:00
);
2019-08-01 01:10:09 +09:00
2020-03-06 23:45:55 +09:00
serviceWorker.register({
onUpdate: (registration) => {
console.log('New version available! Ready to update?');
if (registration && registration.waiting) {
registration.waiting.postMessage({type: 'SKIP_WAITING'});
}
window.location.reload();
},
});