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
1009 B
37 lines
1009 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 "@app/components/App"; |
|
import { AppState, ProvideState } from "@app/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("@app/components/App", () => { |
|
const NextApp = require<any>("@app/components/App").default as typeof App; |
|
doRender(NextApp); |
|
}); |
|
}
|
|
|