-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (30 loc) · 1 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { render } from "inferno";
import App from "./App";
import "./index.css";
import { Router, Route, IndexRoute } from "inferno-router";
import createBrowserHistory from "history/createBrowserHistory";
import { init as authinit, reloadUserinfo } from "./auth";
import "./fetchWithAuth";
import Hello from "./Hello";
import Viewer from "./Viewer";
import ResViewer from "./ResViewer";
const browserHistory = createBrowserHistory();
window.browserHistory = browserHistory;
async function routeChange() {
document.getElementById("navbarToggle").checked = false;
await reloadUserinfo();
}
const routes = (
<Router asyncBefore={routeChange} history={browserHistory}>
<Route path={process.env.PUBLIC_URL} component={App}>
<IndexRoute component={Hello} />
<Route path="/:formslug" component={Viewer} />
<Route path="/:formslug/responses" component={ResViewer} />
</Route>
</Router>
);
async function init() {
await authinit();
render(routes, document.getElementById("app"));
}
init();