diff --git a/app/components/DocumentHistory/DocumentHistory.js b/app/components/DocumentHistory/DocumentHistory.js
index bb4af4d4c..283d37d2e 100644
--- a/app/components/DocumentHistory/DocumentHistory.js
+++ b/app/components/DocumentHistory/DocumentHistory.js
@@ -2,7 +2,7 @@
import * as React from "react";
import { observable, action } from "mobx";
import { observer, inject } from "mobx-react";
-import type { RouterHistory } from "react-router-dom";
+import { type RouterHistory, type Match } from "react-router-dom";
import styled from "styled-components";
import { Waypoint } from "react-waypoint";
import ArrowKeyNavigation from "boundless-arrow-key-navigation";
@@ -17,7 +17,7 @@ import Revision from "./components/Revision";
import { documentHistoryUrl } from "utils/routeHelpers";
type Props = {
- match: Object,
+ match: Match,
documents: DocumentsStore,
revisions: RevisionsStore,
history: RouterHistory,
diff --git a/app/components/DropToImport.js b/app/components/DropToImport.js
index 7276e87bc..3621b226b 100644
--- a/app/components/DropToImport.js
+++ b/app/components/DropToImport.js
@@ -2,7 +2,7 @@
import * as React from "react";
import { observable } from "mobx";
import { observer, inject } from "mobx-react";
-import { withRouter, type RouterHistory } from "react-router-dom";
+import { withRouter, type RouterHistory, type Match } from "react-router-dom";
import { createGlobalStyle } from "styled-components";
import invariant from "invariant";
import importFile from "utils/importFile";
@@ -22,7 +22,7 @@ type Props = {
documents: DocumentsStore,
disabled: boolean,
location: Object,
- match: Object,
+ match: Match,
history: RouterHistory,
staticContext: Object,
};
diff --git a/app/components/HoverPreview.js b/app/components/HoverPreview.js
index f03bb8be0..b5907b79a 100644
--- a/app/components/HoverPreview.js
+++ b/app/components/HoverPreview.js
@@ -29,9 +29,9 @@ function HoverPreview({ node, documents, onClose, event }: Props) {
const slug = parseDocumentSlugFromUrl(node.href);
const [isVisible, setVisible] = React.useState(false);
- const timerClose = React.useRef(null);
- const timerOpen = React.useRef(null);
- const cardRef = React.useRef(null);
+ const timerClose = React.useRef();
+ const timerOpen = React.useRef();
+ const cardRef = React.useRef();
const startCloseTimer = () => {
stopOpenTimer();
diff --git a/app/routes.js b/app/routes.js
index dde9b634e..1e224e42c 100644
--- a/app/routes.js
+++ b/app/routes.js
@@ -1,6 +1,6 @@
// @flow
import * as React from "react";
-import { Switch, Route, Redirect } from "react-router-dom";
+import { Switch, Route, Redirect, type Match } from "react-router-dom";
import Login from "scenes/Login";
import Dashboard from "scenes/Dashboard";
import Starred from "scenes/Starred";
@@ -32,8 +32,12 @@ import Authenticated from "components/Authenticated";
import { matchDocumentSlug as slug } from "utils/routeHelpers";
const NotFound = () => ;
-const RedirectDocument = ({ match }: { match: Object }) => (
-
+const RedirectDocument = ({ match }: { match: Match }) => (
+
);
export default function Routes() {
diff --git a/app/scenes/Collection.js b/app/scenes/Collection.js
index e22155c24..23b18887d 100644
--- a/app/scenes/Collection.js
+++ b/app/scenes/Collection.js
@@ -2,7 +2,7 @@
import * as React from "react";
import { observable } from "mobx";
import { observer, inject } from "mobx-react";
-import { Redirect, Link, Switch, Route } from "react-router-dom";
+import { Redirect, Link, Switch, Route, type Match } from "react-router-dom";
import styled, { withTheme } from "styled-components";
import { NewDocumentIcon, PlusIcon, PinIcon } from "outline-icons";
@@ -43,7 +43,7 @@ type Props = {
documents: DocumentsStore,
collections: CollectionsStore,
policies: PoliciesStore,
- match: Object,
+ match: Match,
theme: Object,
};
@@ -56,12 +56,17 @@ class CollectionScene extends React.Component {
@observable redirectTo: ?string;
componentDidMount() {
- this.loadContent(this.props.match.params.id);
+ const { id } = this.props.match.params;
+ if (id) {
+ this.loadContent(id);
+ }
}
componentWillReceiveProps(nextProps) {
- if (nextProps.match.params.id !== this.props.match.params.id) {
- this.loadContent(nextProps.match.params.id);
+ const { id } = nextProps.match.params;
+
+ if (id && id !== this.props.match.params.id) {
+ this.loadContent(id);
}
}
@@ -111,7 +116,7 @@ class CollectionScene extends React.Component {
renderActions() {
const { match, policies } = this.props;
- const can = policies.abilities(match.params.id);
+ const can = policies.abilities(match.params.id || "");
return (
diff --git a/app/scenes/Document/components/DataLoader.js b/app/scenes/Document/components/DataLoader.js
index a308cfcb2..24c810e2c 100644
--- a/app/scenes/Document/components/DataLoader.js
+++ b/app/scenes/Document/components/DataLoader.js
@@ -2,7 +2,7 @@
import * as React from "react";
import invariant from "invariant";
import { withRouter } from "react-router-dom";
-import type { Location, RouterHistory } from "react-router-dom";
+import type { Location, RouterHistory, Match } from "react-router-dom";
import { observable } from "mobx";
import { observer, inject } from "mobx-react";
import { matchDocumentEdit, updateDocumentUrl } from "utils/routeHelpers";
@@ -22,7 +22,7 @@ import UiStore from "stores/UiStore";
import { OfflineError } from "utils/errors";
type Props = {|
- match: Object,
+ match: Match,
location: Location,
shares: SharesStore,
documents: DocumentsStore,
diff --git a/app/scenes/Document/components/Document.js b/app/scenes/Document/components/Document.js
index 3cbc943f9..145ac45ee 100644
--- a/app/scenes/Document/components/Document.js
+++ b/app/scenes/Document/components/Document.js
@@ -6,7 +6,7 @@ import breakpoint from "styled-components-breakpoint";
import { observable } from "mobx";
import { observer, inject } from "mobx-react";
import { Prompt, Route, withRouter } from "react-router-dom";
-import type { Location, RouterHistory } from "react-router-dom";
+import type { Location, RouterHistory, Match } from "react-router-dom";
import keydown from "react-keydown";
import { InputIcon } from "outline-icons";
import Flex from "components/Flex";
@@ -52,7 +52,7 @@ Are you sure you want to discard them?
`;
type Props = {
- match: Object,
+ match: Match,
history: RouterHistory,
location: Location,
abilities: Object,
@@ -322,10 +322,12 @@ class DocumentScene extends React.Component {
let url;
if (this.props.document.url) {
url = this.props.document.url;
- } else {
+ } else if (this.props.match.params.id) {
url = collectionUrl(this.props.match.params.id);
}
- this.props.history.push(url);
+ if (url) {
+ this.props.history.push(url);
+ }
};
render() {
diff --git a/app/scenes/DocumentNew.js b/app/scenes/DocumentNew.js
index ed6848a74..4bcf3b94c 100644
--- a/app/scenes/DocumentNew.js
+++ b/app/scenes/DocumentNew.js
@@ -2,7 +2,11 @@
import * as React from "react";
import { inject } from "mobx-react";
import queryString from "query-string";
-import type { RouterHistory, Location } from "react-router-dom";
+import {
+ type RouterHistory,
+ type Location,
+ type Match,
+} from "react-router-dom";
import Flex from "components/Flex";
import CenteredContent from "components/CenteredContent";
import LoadingPlaceholder from "components/LoadingPlaceholder";
@@ -15,7 +19,7 @@ type Props = {
location: Location,
documents: DocumentsStore,
ui: UiStore,
- match: Object,
+ match: Match,
};
class DocumentNew extends React.Component {
diff --git a/app/scenes/Search/Search.js b/app/scenes/Search/Search.js
index e32a72ce9..2bf21513d 100644
--- a/app/scenes/Search/Search.js
+++ b/app/scenes/Search/Search.js
@@ -4,7 +4,7 @@ import ReactDOM from "react-dom";
import keydown from "react-keydown";
import { Waypoint } from "react-waypoint";
import { withRouter, Link } from "react-router-dom";
-import type { Location, RouterHistory } from "react-router-dom";
+import type { Location, RouterHistory, Match } from "react-router-dom";
import { PlusIcon } from "outline-icons";
import { observable, action } from "mobx";
import { observer, inject } from "mobx-react";
@@ -37,7 +37,7 @@ import DateFilter from "./components/DateFilter";
type Props = {
history: RouterHistory,
- match: Object,
+ match: Match,
location: Location,
documents: DocumentsStore,
users: UsersStore,
diff --git a/app/scenes/Settings/Events.js b/app/scenes/Settings/Events.js
index 627370060..b58a8184a 100644
--- a/app/scenes/Settings/Events.js
+++ b/app/scenes/Settings/Events.js
@@ -3,6 +3,7 @@ import * as React from "react";
import { observable, action } from "mobx";
import { observer, inject } from "mobx-react";
import { Waypoint } from "react-waypoint";
+import { type Match } from "react-router-dom";
import { DEFAULT_PAGINATION_LIMIT } from "stores/BaseStore";
import EventsStore from "stores/EventsStore";
@@ -17,7 +18,7 @@ import EventListItem from "./components/EventListItem";
type Props = {
events: EventsStore,
- match: Object,
+ match: Match,
};
@observer
diff --git a/app/scenes/Settings/Groups.js b/app/scenes/Settings/Groups.js
index 2d0077056..2de853198 100644
--- a/app/scenes/Settings/Groups.js
+++ b/app/scenes/Settings/Groups.js
@@ -4,6 +4,7 @@ import invariant from "invariant";
import { observable } from "mobx";
import { observer, inject } from "mobx-react";
import { PlusIcon } from "outline-icons";
+import { type Match } from "react-router-dom";
import Empty from "components/Empty";
import { ListPlaceholder } from "components/LoadingPlaceholder";
@@ -27,7 +28,7 @@ type Props = {
auth: AuthStore,
groups: GroupsStore,
policies: PoliciesStore,
- match: Object,
+ match: Match,
};
@observer
diff --git a/app/scenes/Settings/People.js b/app/scenes/Settings/People.js
index 6b8393d74..6cdcea9d4 100644
--- a/app/scenes/Settings/People.js
+++ b/app/scenes/Settings/People.js
@@ -4,6 +4,7 @@ import invariant from "invariant";
import { observable } from "mobx";
import { observer, inject } from "mobx-react";
import { PlusIcon } from "outline-icons";
+import { type Match } from "react-router-dom";
import Empty from "components/Empty";
import Modal from "components/Modal";
@@ -25,7 +26,7 @@ type Props = {
auth: AuthStore,
users: UsersStore,
policies: PoliciesStore,
- match: Object,
+ match: Match,
};
@observer
diff --git a/app/scenes/Starred.js b/app/scenes/Starred.js
index 8e808353f..edf05b176 100644
--- a/app/scenes/Starred.js
+++ b/app/scenes/Starred.js
@@ -1,6 +1,7 @@
// @flow
import * as React from "react";
import { observer, inject } from "mobx-react";
+import { type Match } from "react-router-dom";
import CenteredContent from "components/CenteredContent";
import Empty from "components/Empty";
@@ -16,7 +17,7 @@ import DocumentsStore from "stores/DocumentsStore";
type Props = {
documents: DocumentsStore,
- match: Object,
+ match: Match,
};
@observer
diff --git a/app/scenes/Templates.js b/app/scenes/Templates.js
index baa41d04c..b7e03adb2 100644
--- a/app/scenes/Templates.js
+++ b/app/scenes/Templates.js
@@ -1,6 +1,7 @@
// @flow
import * as React from "react";
import { observer, inject } from "mobx-react";
+import { type Match } from "react-router-dom";
import CenteredContent from "components/CenteredContent";
import Empty from "components/Empty";
@@ -15,7 +16,7 @@ import DocumentsStore from "stores/DocumentsStore";
type Props = {
documents: DocumentsStore,
- match: Object,
+ match: Match,
};
@observer