forked from coldemo/gallery.code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppRouter.tsx
More file actions
34 lines (31 loc) · 833 Bytes
/
AppRouter.tsx
File metadata and controls
34 lines (31 loc) · 833 Bytes
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
import loadable from '@loadable/component';
import React from 'react';
import {
HashRouter as Router,
Redirect,
Route,
Switch,
} from 'react-router-dom';
// react-router code-splitting
// https://reacttraining.com/react-router/web/guides/code-splitting
let Gallery = loadable(async () => {
return (await import('./gallery')).Gallery;
});
let Playground = loadable(async () => {
return (await import('./playground')).Playground;
});
function AppRouter() {
return (
<Router>
<Switch>
<Route path="/" exact component={Gallery} />
<Route path="/playground/:file?" component={Playground} />
<Route path="/playground/:file/**" component={Playground} />
<Route path="*">
<Redirect to="/" />
</Route>
</Switch>
</Router>
);
}
export default AppRouter;