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