added 404 page and made every route load asynchrounously.

This commit is contained in:
Warwick 2022-03-04 15:28:19 +00:00
parent 04f7b54c1a
commit f9668827aa
2 changed files with 39 additions and 6 deletions

28
src/404Page.jsx Normal file
View file

@ -0,0 +1,28 @@
import { h, render, Component } from "preact";
import {
Container,
Card,
CardContent,
Typography,
} from "@material-ui/core";
class LostPage extends Component {
render() {
return (
<span>
<Container maxWidth="sm" >
<Card>
<CardContent>
<Typography variant="h1"> Error 404</Typography>
<Typography variant="body1">
There is no content here...
</Typography>
</CardContent>
</Card>
</Container>
</span>
);
}
}
export default LostPage;

View file

@ -13,11 +13,16 @@ class App extends Component {
<ThemeProvider theme={theme}>
<CssBaseline />
<Router>
<Home path="/" />
<AsyncRoute
path="/contact"
getComponent={() =>
import("./Contact.jsx").then((module) => module.default)
<AsyncRoute path="/" getComponent={() =>
import("./Home").then((module) => module.default)
}
/>
<AsyncRoute path="/contact" getComponent={() =>
import("./Contact").then((module) => module.default)
}
/>
<AsyncRoute default getComponent={() =>
import("./404Page").then((module) => module.default)
}
/>
</Router>