2022-04-22 09:00:14 -06:00
|
|
|
import React from 'react';
|
|
|
|
import { hydrateRoot } from 'react-dom/client';
|
|
|
|
// Router
|
|
|
|
import { BrowserRouter as Router } from 'react-router-dom';
|
|
|
|
// Redux
|
|
|
|
import { Provider } from 'react-redux';
|
2022-04-28 09:15:16 -06:00
|
|
|
import { IInitialState } from './reducers/index';
|
2022-04-22 09:00:14 -06:00
|
|
|
import setStore from './setStore.js';
|
2022-04-25 09:12:43 -06:00
|
|
|
import { config } from '../../config';
|
2022-04-22 09:00:14 -06:00
|
|
|
|
|
|
|
import './styles/global.sass';
|
2022-04-24 23:44:06 -06:00
|
|
|
import App from './components/App';
|
2022-04-25 09:12:43 -06:00
|
|
|
import serviceWorkerRegistration from '../../serviceWorkerRegistration';
|
2022-04-22 09:00:14 -06:00
|
|
|
|
|
|
|
declare global {
|
|
|
|
interface Window {
|
|
|
|
__PRELOADED_STATE__?: IInitialState;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
declare global {
|
|
|
|
interface NodeModule {
|
|
|
|
hot?: IHot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
interface IHot {
|
|
|
|
accept: any
|
|
|
|
}
|
|
|
|
|
2022-04-24 23:44:06 -06:00
|
|
|
const { env } = config;
|
|
|
|
|
2022-04-22 09:00:14 -06:00
|
|
|
const preloadedState = window.__PRELOADED_STATE__;
|
|
|
|
const store = setStore({ initialState: preloadedState });
|
|
|
|
|
|
|
|
delete window.__PRELOADED_STATE__;
|
|
|
|
|
|
|
|
const container = document.getElementById('app')!;
|
|
|
|
|
|
|
|
// add "const root" to be able to rerender.
|
|
|
|
hydrateRoot(container,
|
|
|
|
<Provider store={store}>
|
|
|
|
<Router>
|
|
|
|
<App />
|
|
|
|
</Router>
|
|
|
|
</Provider>,
|
|
|
|
// Add this comment to update later app and remove warning
|
|
|
|
/* {
|
|
|
|
onRecoverableError: (error) => {
|
|
|
|
console.error("recoverable", error);
|
|
|
|
}
|
|
|
|
}, */
|
|
|
|
);
|
|
|
|
|
|
|
|
// Use root.render to update later the app
|
|
|
|
/* root.render(
|
|
|
|
<Provider store={store}>
|
|
|
|
<Router>
|
|
|
|
<App />
|
|
|
|
</Router>
|
|
|
|
</Provider>
|
|
|
|
); */
|
|
|
|
|
2022-04-24 23:44:06 -06:00
|
|
|
// 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: http://bit.ly/CRA-PWA
|
|
|
|
//serviceWorker.register();
|
|
|
|
|
|
|
|
if((env) && (env === 'production')){
|
|
|
|
serviceWorkerRegistration();
|
|
|
|
}
|
|
|
|
|
2022-04-22 09:00:14 -06:00
|
|
|
if(module.hot){
|
|
|
|
module.hot.accept();
|
2022-04-24 23:44:06 -06:00
|
|
|
}
|