2017-05-02 20:03:48 -06:00
|
|
|
import * as React from "react";
|
|
|
|
import * as ReactDOM from "react-dom";
|
2017-08-29 22:42:56 -06:00
|
|
|
import { AppContainer } from "react-hot-loader";
|
2018-07-02 15:22:59 -06:00
|
|
|
import { Router } from "react-router-dom";
|
2017-05-02 20:03:48 -06:00
|
|
|
|
2018-08-11 20:11:31 +03:00
|
|
|
import App from "@client/App";
|
2018-08-07 21:21:26 +03:00
|
|
|
import { AppState, ProvideState } from "@client/state";
|
2018-07-01 02:00:17 -06:00
|
|
|
import logger from "@common/logger";
|
2017-09-10 12:30:23 -06:00
|
|
|
|
2018-07-02 15:22:59 -06:00
|
|
|
const state = new AppState();
|
2018-09-02 02:57:55 -06:00
|
|
|
state.start().catch((err: any) => {
|
|
|
|
logger.error({ err }, "error starting state");
|
|
|
|
});
|
2017-05-02 20:03:48 -06:00
|
|
|
|
2017-05-04 13:35:33 -06:00
|
|
|
const rootElem = document.getElementById("app");
|
2017-05-02 20:03:48 -06:00
|
|
|
|
2017-09-10 12:30:23 -06:00
|
|
|
const doRender = (Component: React.ComponentType) => {
|
2018-09-02 02:57:55 -06:00
|
|
|
ReactDOM.render(
|
|
|
|
<AppContainer>
|
|
|
|
<ProvideState state={state}>
|
|
|
|
<Router history={state.history}>
|
|
|
|
<Component />
|
|
|
|
</Router>
|
|
|
|
</ProvideState>
|
|
|
|
</AppContainer>,
|
|
|
|
rootElem
|
|
|
|
);
|
2017-08-29 23:21:36 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
doRender(App);
|
2017-05-03 16:12:51 -06:00
|
|
|
|
|
|
|
if (module.hot) {
|
2018-09-02 02:57:55 -06:00
|
|
|
module.hot.accept("@client/App", () => {
|
|
|
|
const NextApp = require<any>("@client/App").default as typeof App;
|
|
|
|
doRender(NextApp);
|
|
|
|
});
|
2017-05-06 15:39:25 -06:00
|
|
|
}
|