You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

37 lines
988 B

import * as React from "react";
import * as ReactDOM from "react-dom";
import { AppContainer } from "react-hot-loader";
import { Router } from "react-router-dom";
import App from "@client/App";
import { AppState, ProvideState } from "@client/state";
import logger from "@common/logger";
const state = new AppState();
state.start()
.catch((err: any) => {
logger.error({ err }, "error starting state");
});
const rootElem = document.getElementById("app");
const doRender = (Component: React.ComponentType) => {
ReactDOM.render((
<AppContainer>
<ProvideState state={state}>
<Router history={state.history}>
<Component/>
</Router>
</ProvideState>
</AppContainer>
), rootElem);
};
doRender(App);
if (module.hot) {
module.hot.accept("@client/App", () => {
const NextApp = require<any>("@client/App").default as typeof App;
doRender(NextApp);
});
}