@@ -165,17 +168,11 @@ export class DocumentEditComponent extends React.PureComponent<
this.props.fetchDocs();
} else {
const { id } = this.props.match.params as any;
- if (
- !this.state.loaded &&
- this.props.allDocs &&
- this.props.allDocs[id]
- ) {
- const doc = this.props.allDocs[id];
-
+ if (!this.state.loaded && this.props.allDocs) {
this.setState({
...this.state,
loaded: true,
- id: doc.id,
+ id,
});
}
}
diff --git a/frontend/src/Documents/DocumentView.tsx b/frontend/src/Documents/DocumentView.tsx
index 285183c..393f20a 100644
--- a/frontend/src/Documents/DocumentView.tsx
+++ b/frontend/src/Documents/DocumentView.tsx
@@ -8,6 +8,7 @@ import { RouteComponentProps, withRouter } from "react-router";
import { Dispatch } from "redux";
import { IDocumentJSON } from "~../../src/entity/Document";
import { LoadingStub } from "~LoadingStub";
+import { NotFound } from "~NotFound";
import { fetchDocsStart } from "~redux/docs/actions";
import { IAppState } from "~redux/reducers";
import { CodeBlock } from "./CodeBlock";
@@ -27,8 +28,12 @@ export class DocumentViewComponent extends React.PureComponent<
> {
public render() {
const { id } = this.props.match.params as any;
- if (this.props.allDocs && this.props.allDocs[id]) {
+ if (this.props.allDocs) {
const doc = this.props.allDocs[id];
+ if (!doc) {
+ return
;
+ }
+
return (
diff --git a/frontend/src/Home/Home.tsx b/frontend/src/Home/Home.tsx
index b8cee68..a59214e 100644
--- a/frontend/src/Home/Home.tsx
+++ b/frontend/src/Home/Home.tsx
@@ -58,11 +58,13 @@ export class HomeComponent extends React.PureComponent
{
if ((this.props.match.params as any).id && this.props.allDocs) {
const { id } = this.props.match.params as any;
- breadcrumbs.push({
- icon: "document",
- text: this.props.allDocs[id].name,
- onClick: () => this.props.history.push(`/docs/${id}`),
- });
+ if (this.props.allDocs[id]) {
+ breadcrumbs.push({
+ icon: "document",
+ text: this.props.allDocs[id].name,
+ onClick: () => this.props.history.push(`/docs/${id}`),
+ });
+ }
}
return (
@@ -82,8 +84,8 @@ export class HomeComponent extends React.PureComponent {
{this.props.uploading || this.props.dirty ? (
) : (
-
- )}
+
+ )}
{
onClick={this.props.dispatchToggleDarkMode}
/>
) : (
-
- )}
+
+ )}
);
}
diff --git a/frontend/src/NotFound.tsx b/frontend/src/NotFound.tsx
new file mode 100644
index 0000000..fbe2649
--- /dev/null
+++ b/frontend/src/NotFound.tsx
@@ -0,0 +1,5 @@
+import * as React from "react";
+
+export function NotFound() {
+ return 404
;
+}